再减少一点框架依赖

This commit is contained in:
MrZ626
2021-10-25 15:45:20 +08:00
parent a136d01da5
commit 423173413f
2 changed files with 15 additions and 14 deletions

View File

@@ -349,9 +349,9 @@ function love.directorydropped(dir)
end
local lastGCtime=0
function love.lowmemory()
if TIME()-lastGCtime>6.26 then
if love.timer.getTime()-lastGCtime>6.26 then
collectgarbage()
lastGCtime=TIME()
lastGCtime=love.timer.getTime()
MES.new('check',"[auto GC] low MEM 设备内存过低")
end
end
@@ -524,10 +524,10 @@ function love.run()
local FPS,MINI=love.timer.getFPS,love.window.isMinimized
local PUMP,POLL=love.event.pump,love.event.poll
local TIME,SETTING,VERSION=TIME,SETTING,VERSION
local timer,SETTING,VERSION=love.timer.getTime,SETTING,VERSION
local frameTimeList={}
local lastFrame=TIME()
local lastFrame=timer()
local lastFreshPow=lastFrame
local FCT=0--Framedraw counter, from 0~99
@@ -541,7 +541,7 @@ function love.run()
return function()
local _
local time=TIME()
local time=timer()
local dt=time-lastFrame
lastFrame=time
@@ -693,9 +693,9 @@ function love.run()
end
--Keep 60fps
_=TIME()-lastFrame
_=timer()-lastFrame
if _<.0162 then WAIT(.0162-_)end
while TIME()-lastFrame<1/60 do end
while timer()-lastFrame<1/60 do end
end
end

View File

@@ -10,6 +10,7 @@ local gc_rectangle=gc.rectangle
local gc_print,gc_printf=gc.print,gc.printf
local kb=love.keyboard
local timer=love.timer.getTime
local next=next
local int,ceil,abs=math.floor,math.ceil,math.abs
@@ -571,8 +572,8 @@ function slider:drag(x)
if p~=P then
self.code(P)
end
if self.change and TIME()-self.lastTime>.5 then
self.lastTime=TIME()
if self.change and timer()-self.lastTime>.5 then
self.lastTime=timer()
self.change()
end
end
@@ -586,8 +587,8 @@ function slider:scroll(n)
local P=n==-1 and max(p-u,0)or min(p+u,self.unit)
if p==P or not P then return end
self.code(P)
if self.change and TIME()-self.lastTime>.18 then
self.lastTime=TIME()
if self.change and timer()-self.lastTime>.18 then
self.lastTime=timer()
self.change()
end
end
@@ -697,7 +698,7 @@ function selector:draw()
--Arrow
gc_setColor(1,1,1,.2+ATV*.1)
local t=(TIME()%.5)^.5
local t=(timer()%.5)^.5
if self.select>1 then
gc_draw(smallerThen,x+6,y+33)
if ATV>0 then
@@ -1457,8 +1458,8 @@ function WIDGET.gamepadPressed(i)
local P=i=="left"and(p>0 and p-1)or p<W.unit and p+1
if p==P or not P then return end
W.code(P)
if W.change and TIME()-W.lastTime>.18 then
W.lastTime=TIME()
if W.change and timer()-W.lastTime>.18 then
W.lastTime=timer()
W.change()
end
end