整理代码,部分协程创建/执行改用wrap更加简洁

This commit is contained in:
MrZ626
2021-04-01 14:47:54 +08:00
parent 5d728573cd
commit 78b7dfcc36
7 changed files with 35 additions and 43 deletions

View File

@@ -36,7 +36,7 @@ local function upFloor()
SFX.play("click",.3)
end
end
local loadingThread=coroutine.create(function()
local loadingThread=coroutine.wrap(function()
for i=1,SFX.getCount()do
SFX.loadOne()
if i%3==0 then YIELD()end
@@ -175,7 +175,6 @@ local loadingThread=coroutine.create(function()
logoColor2={COLOR.rainbow_light(r)}
end
STAT.run=STAT.run+1
LOADED=true
--Connect to server
TASK.new(NET.TICK_WS_app)
@@ -194,10 +193,10 @@ local loadingThread=coroutine.create(function()
upFloor()
end
if progress==25 then
loadingThread=false
SFX.play("welcome_sfx")
VOC.play("welcome_voc")
THEME.fresh()
LOADED=true
return
end
YIELD()
@@ -256,8 +255,8 @@ function scene.update(dt)
if progress<25 then
local p=progress
repeat
assert(coroutine.resume(loadingThread))
until not loadingThread or skip<=0 or progress~=p
loadingThread()
until LOADED or skip<=0 or progress~=p
if skip>0 then skip=skip-1 end
else
openTime=openTime+dt