From 27a9697e47b23c3b324f975c008312a53fe2d73d Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Tue, 7 Dec 2021 15:04:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9scene=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E5=9C=A8=E5=88=87=E6=8D=A2=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E7=9A=84=E6=97=B6=E5=80=99=E4=BC=A0=E5=8F=82=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/scene.lua | 20 ++++++++++++-------- parts/scenes/game.lua | 4 ++-- parts/scenes/mode.lua | 4 ++-- parts/scenes/net_game.lua | 4 ++-- parts/scenes/pause.lua | 6 +++--- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Zframework/scene.lua b/Zframework/scene.lua index da06ce44..e990c71b 100644 --- a/Zframework/scene.lua +++ b/Zframework/scene.lua @@ -15,6 +15,8 @@ local SCN={ draw=false, --Swap draw func }, stack={},--Scene stack + prev=false, + args={},--Arguments from previous scene scenes=scenes, @@ -52,14 +54,15 @@ function SCN.swapUpdate(dt) S.time=S.time-dt if S.time=S.changeTime then --Scene swapped this frame - SCN.init(S.tar,SCN.cur) + SCN.prev=SCN.cur + SCN.init(S.tar) SCN.mainTouchID=nil end if S.time<0 then SCN.swapping=false end end -function SCN.init(s,org) +function SCN.init(s) love.keyboard.setTextInput(false) local S=scenes[s] @@ -89,7 +92,7 @@ function SCN.init(s,org) SCN.update=S.update SCN.draw=S.draw if S.sceneInit then - S.sceneInit(org) + S.sceneInit() end end function SCN.push(tar,style) @@ -165,11 +168,12 @@ local swap={ end }, }--Scene swapping animations -function SCN.swapTo(tar,style)--Parallel scene swapping, cannot back +function SCN.swapTo(tar,style,...)--Parallel scene swapping, cannot back if scenes[tar]then if not SCN.swapping and tar~=SCN.cur then style=style or'fade' SCN.swapping=true + SCN.args={...} local S=SCN.stat S.tar,S.style=tar,style S.time=swap[style].duration @@ -180,15 +184,15 @@ function SCN.swapTo(tar,style)--Parallel scene swapping, cannot back MES.new('warn',"No Scene: "..tar) end end -function SCN.go(tar,style)--Normal scene swapping, can back +function SCN.go(tar,style,...)--Normal scene swapping, can back if scenes[tar]then SCN.push() - SCN.swapTo(tar,style) + SCN.swapTo(tar,style,...) else MES.new('warn',"No Scene: "..tar) end end -function SCN.back() +function SCN.back(...) if SCN.swapping then return end --Leave scene @@ -199,7 +203,7 @@ function SCN.back() --Poll&Back to previous Scene local m=#SCN.stack if m>0 then - SCN.swapTo(SCN.stack[m-1],SCN.stack[m]) + SCN.swapTo(SCN.stack[m-1],SCN.stack[m],...) SCN.stack[m],SCN.stack[m-1]=nil end end diff --git a/parts/scenes/game.lua b/parts/scenes/game.lua index dc97fd6b..1533e67d 100644 --- a/parts/scenes/game.lua +++ b/parts/scenes/game.lua @@ -135,7 +135,7 @@ local function _checkGameKeyDown(key) return true--No key pressed end -function scene.sceneInit(org) +function scene.sceneInit() if GAME.init then resetGameData() GAME.init=false @@ -145,7 +145,7 @@ function scene.sceneInit(org) noKey=replaying noTouch=not SETTING.VKSwitch or replaying - if org~='depause'and org~='pause'then + if SCN.prev~='depause'and SCN.prev~='pause'then trigGameRate,gameRate=0,1 elseif not replaying then if GAME.tasUsed then diff --git a/parts/scenes/mode.lua b/parts/scenes/mode.lua index ca9a7913..f3deee66 100644 --- a/parts/scenes/mode.lua +++ b/parts/scenes/mode.lua @@ -28,9 +28,9 @@ local touchDist local scene={} -function scene.sceneInit(org) +function scene.sceneInit() BG.set() - mapCam.zoomK=org=='main'and 5 or 1 + mapCam.zoomK=SCN.prev=='main'and 5 or 1 visibleModes={}--1=unlocked, 2=locked but visible for name,M in next,MODES do if RANKS[name]and M.x then diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index a6abd56a..facd71e7 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -57,7 +57,7 @@ end local scene={} -function scene.sceneInit(org) +function scene.sceneInit() textBox.hide=true textBox:clear() inputBox.hide=true @@ -68,7 +68,7 @@ function scene.sceneInit(org) upstreamProgress=1 newMessageTimer=0 - if org=='setting_game'then + if SCN.prev=='setting_game'then NET.changeConfig() end if GAME.prevBG then diff --git a/parts/scenes/pause.lua b/parts/scenes/pause.lua index b000b44e..d4ffbdfc 100644 --- a/parts/scenes/pause.lua +++ b/parts/scenes/pause.lua @@ -17,15 +17,15 @@ local rank--Current rank local trophy--Current trophy local trophyColor--Current trophy color -function scene.sceneInit(org) +function scene.sceneInit() page=0 - if org:find("setting")then + if SCN.prev:find("setting")then TEXT.show(text.needRestart,640,410,50,'fly',.6) end local P1=PLAYERS[1] local S=P1.stat - timer1=org=='game'and 0 or 50 + timer1=SCN.prev=='game'and 0 or 50 timer2=timer1 local frameLostRate=(S.frame/S.time/60-1)*100