I have a problem whereby when I call storyboard.purgeScene(), my global display objects seem to be removed. When I say ‘global’, they I actually store them in a user-defined storyboard table, to avoid using actual global variables:
My image database is stored in external file toy_database.lua:
[lua] local storyboard = require “storyboard”;
storyboard.globalVars.toys = {
ball1 = {
src = ‘img/stock-vector-soccer-ball-trimmed.png’,
}
}[/lua]
main.lua:
[lua] local storyboard = require “storyboard”;
storyboard.globalVars = {};
require “toy_database_toybox”;[/lua]
I load some images in my main.lua:
[lua] storyboard.globalVars.toys[“ball1”].imgPtr = display.newImageRect(storyboard.globalVars.toys[“ball1”].src, w, h);[/lua]
Then I go to another scene:
[lua] storyboard.gotoScene(“mainFloorScene”);[/lua]
where everything is fine, the display objects are accessable. I purge that scene and goto another scene:
[lua] storyboard.gotoScene( “openBoxScene” )
[in didExitScene()]: storyboard.purgeScene( “mainFloorScene” )[/lua]
Everything is fine here too. Finally I go back to the first scene, purging the current scene on the way:
[lua] storyboard.gotoScene( “mainFloorScene”, “fade”, 400 );
[in didExitScene()]: storyboard.purgeScene( “openBoxScene” )[/lua]
Back in the first scene the image objects have been removed. If I comment out the line:
[lua] storyboard.purgeScene( “openBoxScene” )[/lua]
it works fine, so I have a workaround but I’d like this behaviour explained. I expected a scene purge to only remove display objects local to that scene.
What’s going on?
[import]uid: 133169 topic_id: 32171 reply_id: 332171[/import]