Zframework的控件/场景/文本/任务模块支持基于时间更新

修改几处其他地方基于时间update
This commit is contained in:
MrZ626
2021-09-25 02:55:01 +08:00
parent 7ae314fb2c
commit 391821bf16
9 changed files with 121 additions and 101 deletions

View File

@@ -6,14 +6,19 @@ local TASK={}
function TASK.getCount()
return #tasks
end
function TASK.update()
for i=#tasks,1,-1 do
local T=tasks[i]
if status(T.thread)=='dead'then
rem(tasks,i)
else
assert(resume(T.thread))
local trigTime=0
function TASK.update(dt)
trigTime=trigTime+dt
while trigTime>1/60 do
for i=#tasks,1,-1 do
local T=tasks[i]
if status(T.thread)=='dead'then
rem(tasks,i)
else
assert(resume(T.thread))
end
end
trigTime=trigTime-1/60
end
end
function TASK.new(code,...)