Storyboard - PurgeScene (What is Best Practice for potentially arriving from different scenes?)

Hi,

I have a simple question about storyboard.PurgeScene and avoiding memory leaks. I can arrive to Scene4 via several scenes (scene4zpanel, scene1, scene3). Is it better to list the purgeScenes this like this? Or set up a global variable and do if/then statement to test for previous scene (Only purging the previous). Or would purgall be more appropriate since I only have 1 out 3 scenes to really purge at any given time.

function scene:enterScene( event )
print( “1: enterScene event” )
– remove previous scene’s view
storyboard.purgeScene( “scene4zpanel” )
storyboard.purgeScene( “scene1” )
storyboard.purgeScene( “scene3” )
end

Thanks! [import]uid: 133581 topic_id: 32184 reply_id: 332184[/import]

I use this piece of code in the ‘scene enter’ part of my game over scene, as my current app needs to reload the game scene every time it is called. Maybe you can do something like this instead of listing all the scenes to purge / remove.

[lua]function scene:enterScene( event )
local group = self.view

– get the name of the last scene
local lastScene = storyboard.getPrevious()

– remove the last scene
storyboard.removeScene(lastScene)
end[/lua] [import]uid: 62706 topic_id: 32184 reply_id: 128126[/import]

use storyboard.purgeAll()
[import]uid: 19626 topic_id: 32184 reply_id: 128163[/import]

Thank you both! I’ll definitely take this knowledge and do some recoding. [import]uid: 133581 topic_id: 32184 reply_id: 128175[/import]

I use this piece of code in the ‘scene enter’ part of my game over scene, as my current app needs to reload the game scene every time it is called. Maybe you can do something like this instead of listing all the scenes to purge / remove.

[lua]function scene:enterScene( event )
local group = self.view

– get the name of the last scene
local lastScene = storyboard.getPrevious()

– remove the last scene
storyboard.removeScene(lastScene)
end[/lua] [import]uid: 62706 topic_id: 32184 reply_id: 128126[/import]

use storyboard.purgeAll()
[import]uid: 19626 topic_id: 32184 reply_id: 128163[/import]

Thank you both! I’ll definitely take this knowledge and do some recoding. [import]uid: 133581 topic_id: 32184 reply_id: 128175[/import]