Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Scene Manager and keeping scene state — Gideros Forum

Scene Manager and keeping scene state

eclisseeclisse Member
edited June 2013 in General questions
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

Sign In or Register to comment.