Hi all
Probably a stupid question, but I'd like to use Scene Manager to pause the game, open an Options screen, then be able to go back to the previous scene with the same state of the game running previously.
I see that Scene Manager effectively destroys the scene after transitioning out and creates a new one transitioning in.
I've tried keeping a table of active scenes, like this
function SceneManager:changeScene(scene, duration, transition, ease)
if self.tweening then
return
end
if self.scene1 == nil then
if self.scenesActive[scene] == nil then self.scenesActive[scene] = self.scenes[scene].new() end
self.scene1 = self.scenesActive[scene]
self:addChild(self.scene1)
dispatchEvent(self, "transitionBegin")
dispatchEvent(self.scene1, "transitionInBegin")
dispatchEvent(self, "transitionEnd")
dispatchEvent(self.scene1, "transitionInEnd")
return
end
self.duration = duration
self.transition = transition
self.ease = ease or defaultEase
if self.scenesActive[scene] == nil then self.scenesActive[scene] = self.scenes[scene].new() end
self.scene2 = self.scenesActive[scene]
self.scene2:setVisible(false)
self:addChild(self.scene2)
self.time = 0
self.currentTimer = os.timer()
self.tweening = true
end
but when I go back to my previous scene nothing is shown on the screen (events get fired again and the state of internal variables is there, but nothing on screen...)
What am I missing ? Or is there (surely) a better way to accomplish this ?
Thanks in advance.
Cheers,
Paolo
Comments
You can check an example Popup class here:
https://github.com/ar2rsawseen/GameTemplate
Also @bowerandy had a great popup class http://www.giderosmobile.com/forum/discussion/1194/popup-in-scene-manager#Item_9
unfortunately I can't find his repo right now.
Anyway, if you can spot what's wrong with my modifications to the code (I can't figure out why state is kept but nothing is shown !) I'd be very grateful !
Cheers,
Paolo
https://github.com/bowerhaus/BhPopup
best regards
I've attached my test project and as you'll see, you can change scenes by clicking and images would remain the same for each scene, but init is executed only once for each scene
>the BhPopup class is here:
>https://github.com/bowerhaus/BhPopup
https://github.com/bowerhaus/BhPopup/blob/master/README.md
and
http://bowerhaus.eu/blog/files/moving_to_github.html
Also you need to copy over the original scenemanager.lua and easing.lua (supplied by Gideros) into the Library folder. These are here:
https://github.com/gideros/Scene-Manager
best regards
@bowerandy Bhpopup is excellent, I've used it and as pointed out by @ar2rsawseen I can use it to obtain what I needed (overlaying an options menu).
@ar2rsawseen thanks for suggestions and I'll examine your example project to understand my error, surely I made some newbie mistake.
Cheers,
Paolo