再减少一点框架依赖

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

View File

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