修改scene模块,支持在切换场景的时候传参了
This commit is contained in:
@@ -15,6 +15,8 @@ local SCN={
|
|||||||
draw=false, --Swap draw func
|
draw=false, --Swap draw func
|
||||||
},
|
},
|
||||||
stack={},--Scene stack
|
stack={},--Scene stack
|
||||||
|
prev=false,
|
||||||
|
args={},--Arguments from previous scene
|
||||||
|
|
||||||
scenes=scenes,
|
scenes=scenes,
|
||||||
|
|
||||||
@@ -52,14 +54,15 @@ function SCN.swapUpdate(dt)
|
|||||||
S.time=S.time-dt
|
S.time=S.time-dt
|
||||||
if S.time<S.changeTime and S.time+dt>=S.changeTime then
|
if S.time<S.changeTime and S.time+dt>=S.changeTime then
|
||||||
--Scene swapped this frame
|
--Scene swapped this frame
|
||||||
SCN.init(S.tar,SCN.cur)
|
SCN.prev=SCN.cur
|
||||||
|
SCN.init(S.tar)
|
||||||
SCN.mainTouchID=nil
|
SCN.mainTouchID=nil
|
||||||
end
|
end
|
||||||
if S.time<0 then
|
if S.time<0 then
|
||||||
SCN.swapping=false
|
SCN.swapping=false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function SCN.init(s,org)
|
function SCN.init(s)
|
||||||
love.keyboard.setTextInput(false)
|
love.keyboard.setTextInput(false)
|
||||||
|
|
||||||
local S=scenes[s]
|
local S=scenes[s]
|
||||||
@@ -89,7 +92,7 @@ function SCN.init(s,org)
|
|||||||
SCN.update=S.update
|
SCN.update=S.update
|
||||||
SCN.draw=S.draw
|
SCN.draw=S.draw
|
||||||
if S.sceneInit then
|
if S.sceneInit then
|
||||||
S.sceneInit(org)
|
S.sceneInit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function SCN.push(tar,style)
|
function SCN.push(tar,style)
|
||||||
@@ -165,11 +168,12 @@ local swap={
|
|||||||
end
|
end
|
||||||
},
|
},
|
||||||
}--Scene swapping animations
|
}--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 scenes[tar]then
|
||||||
if not SCN.swapping and tar~=SCN.cur then
|
if not SCN.swapping and tar~=SCN.cur then
|
||||||
style=style or'fade'
|
style=style or'fade'
|
||||||
SCN.swapping=true
|
SCN.swapping=true
|
||||||
|
SCN.args={...}
|
||||||
local S=SCN.stat
|
local S=SCN.stat
|
||||||
S.tar,S.style=tar,style
|
S.tar,S.style=tar,style
|
||||||
S.time=swap[style].duration
|
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)
|
MES.new('warn',"No Scene: "..tar)
|
||||||
end
|
end
|
||||||
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
|
if scenes[tar]then
|
||||||
SCN.push()
|
SCN.push()
|
||||||
SCN.swapTo(tar,style)
|
SCN.swapTo(tar,style,...)
|
||||||
else
|
else
|
||||||
MES.new('warn',"No Scene: "..tar)
|
MES.new('warn',"No Scene: "..tar)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function SCN.back()
|
function SCN.back(...)
|
||||||
if SCN.swapping then return end
|
if SCN.swapping then return end
|
||||||
|
|
||||||
--Leave scene
|
--Leave scene
|
||||||
@@ -199,7 +203,7 @@ function SCN.back()
|
|||||||
--Poll&Back to previous Scene
|
--Poll&Back to previous Scene
|
||||||
local m=#SCN.stack
|
local m=#SCN.stack
|
||||||
if m>0 then
|
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
|
SCN.stack[m],SCN.stack[m-1]=nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ local function _checkGameKeyDown(key)
|
|||||||
return true--No key pressed
|
return true--No key pressed
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.sceneInit(org)
|
function scene.sceneInit()
|
||||||
if GAME.init then
|
if GAME.init then
|
||||||
resetGameData()
|
resetGameData()
|
||||||
GAME.init=false
|
GAME.init=false
|
||||||
@@ -145,7 +145,7 @@ function scene.sceneInit(org)
|
|||||||
noKey=replaying
|
noKey=replaying
|
||||||
noTouch=not SETTING.VKSwitch or 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
|
trigGameRate,gameRate=0,1
|
||||||
elseif not replaying then
|
elseif not replaying then
|
||||||
if GAME.tasUsed then
|
if GAME.tasUsed then
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ local touchDist
|
|||||||
|
|
||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneInit(org)
|
function scene.sceneInit()
|
||||||
BG.set()
|
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
|
visibleModes={}--1=unlocked, 2=locked but visible
|
||||||
for name,M in next,MODES do
|
for name,M in next,MODES do
|
||||||
if RANKS[name]and M.x then
|
if RANKS[name]and M.x then
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ end
|
|||||||
|
|
||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneInit(org)
|
function scene.sceneInit()
|
||||||
textBox.hide=true
|
textBox.hide=true
|
||||||
textBox:clear()
|
textBox:clear()
|
||||||
inputBox.hide=true
|
inputBox.hide=true
|
||||||
@@ -68,7 +68,7 @@ function scene.sceneInit(org)
|
|||||||
upstreamProgress=1
|
upstreamProgress=1
|
||||||
newMessageTimer=0
|
newMessageTimer=0
|
||||||
|
|
||||||
if org=='setting_game'then
|
if SCN.prev=='setting_game'then
|
||||||
NET.changeConfig()
|
NET.changeConfig()
|
||||||
end
|
end
|
||||||
if GAME.prevBG then
|
if GAME.prevBG then
|
||||||
|
|||||||
@@ -17,15 +17,15 @@ local rank--Current rank
|
|||||||
local trophy--Current trophy
|
local trophy--Current trophy
|
||||||
local trophyColor--Current trophy color
|
local trophyColor--Current trophy color
|
||||||
|
|
||||||
function scene.sceneInit(org)
|
function scene.sceneInit()
|
||||||
page=0
|
page=0
|
||||||
if org:find("setting")then
|
if SCN.prev:find("setting")then
|
||||||
TEXT.show(text.needRestart,640,410,50,'fly',.6)
|
TEXT.show(text.needRestart,640,410,50,'fly',.6)
|
||||||
end
|
end
|
||||||
local P1=PLAYERS[1]
|
local P1=PLAYERS[1]
|
||||||
local S=P1.stat
|
local S=P1.stat
|
||||||
|
|
||||||
timer1=org=='game'and 0 or 50
|
timer1=SCN.prev=='game'and 0 or 50
|
||||||
timer2=timer1
|
timer2=timer1
|
||||||
|
|
||||||
local frameLostRate=(S.frame/S.time/60-1)*100
|
local frameLostRate=(S.frame/S.time/60-1)*100
|
||||||
|
|||||||
Reference in New Issue
Block a user