After the image is pressed it is removed and storyboard goes to next scene; however if I try to come back from a scene to this scene if I press again the image I get the following error:
If you don’t purge the scene on exit, the method “createScene” will not be called. Try to include those statements in “enterScene” or purging the scene on exit.
Mmmm. Did you tried to remove the touch event listener? If you are using globals maybe it is still running when you enter again in the scene… Try to remove it or using a print in the “began” event, just to check how many events are triggered when you touch.
storyboard.purgeAll() will not purge the current scene, which is the one you need purged. What might be the best practice is if you know you’re going to a scene named “level1” to do a storyboard.purgeScene(“levell1”) just before you do the storyboard.gotoScene(“level1”).
That way you’re not purging excessive scenes, you’re targeting the one you are going to. Be aware that if you create any varaibles outside of the scene functions, i.e.
[lua]
local x = 10
function scene:createScene(event)
…
end
[/lua]
And something changes the value of x during the scene’s run, it will still be that last value when you return regardless of if you purge or not. You have to remove the scene to reset those variables defined in the main chunk. You can create them outside of the createScene() type functions for scope purposes, but you should initialize them inside of createScene() to make sure they reset properly.
If you don’t purge the scene on exit, the method “createScene” will not be called. Try to include those statements in “enterScene” or purging the scene on exit.
Mmmm. Did you tried to remove the touch event listener? If you are using globals maybe it is still running when you enter again in the scene… Try to remove it or using a print in the “began” event, just to check how many events are triggered when you touch.
storyboard.purgeAll() will not purge the current scene, which is the one you need purged. What might be the best practice is if you know you’re going to a scene named “level1” to do a storyboard.purgeScene(“levell1”) just before you do the storyboard.gotoScene(“level1”).
That way you’re not purging excessive scenes, you’re targeting the one you are going to. Be aware that if you create any varaibles outside of the scene functions, i.e.
[lua]
local x = 10
function scene:createScene(event)
…
end
[/lua]
And something changes the value of x during the scene’s run, it will still be that last value when you return regardless of if you purge or not. You have to remove the scene to reset those variables defined in the main chunk. You can create them outside of the createScene() type functions for scope purposes, but you should initialize them inside of createScene() to make sure they reset properly.