整理代码,部分协程创建/执行改用wrap更加简洁
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -12,15 +12,13 @@ local widgetX0={
|
||||
1290,1290,1290,1290,
|
||||
}
|
||||
|
||||
local cmdEntryThread=coroutine.create(function()
|
||||
local cmdEntryThread=coroutine.wrap(function()
|
||||
while true do
|
||||
while true do
|
||||
if YIELD()~="c"then break end
|
||||
SFX.play("ren_6")
|
||||
if YIELD()~="m"then break end
|
||||
SFX.play("ren_9")
|
||||
if YIELD()~="d"then break end
|
||||
SFX.play("ren_11")
|
||||
if
|
||||
YIELD()=="c"and(SFX.play("ren_6")or 1)and
|
||||
YIELD()=="m"and(SFX.play("ren_9")or 1)and
|
||||
YIELD()=="d"and(SFX.play("ren_11")or 1)
|
||||
then
|
||||
SCN.go("app_cmd")
|
||||
end
|
||||
end
|
||||
@@ -30,7 +28,7 @@ function scene.sceneInit()
|
||||
scrollX=tipLength
|
||||
|
||||
BG.set()
|
||||
coroutine.resume(cmdEntryThread)
|
||||
cmdEntryThread()
|
||||
|
||||
--Set quick-play-button text
|
||||
scene.widgetList[2].text=text.WidgetText.main.qplay..": "..text.modes[STAT.lastPlay][1]
|
||||
@@ -47,7 +45,7 @@ end
|
||||
|
||||
function scene.mouseDown(x,y)
|
||||
if x>=520 and x<=760 and y>=140 and y<=620 then
|
||||
coroutine.resume(cmdEntryThread,
|
||||
cmdEntryThread(
|
||||
x<520+80 and y>620-80 and"c"or
|
||||
x>760-80 and y>620-80 and"m"or
|
||||
x<520+80 and y<140+80 and"d"
|
||||
@@ -121,7 +119,7 @@ function scene.keyDown(key)
|
||||
SCN.back()
|
||||
end
|
||||
else
|
||||
coroutine.resume(cmdEntryThread,key)
|
||||
cmdEntryThread(key)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user