I’m working with storyboard and I have a logic file that manages all the logic for the level. First time I go to the level it works fine, but when I upload the level and go to a new level the logic file that is local to the previous level is still loaded and it throws an error. Is there a way to remove the logic when the level is unloaded?
What happens when you call
and
in the exitScene() function of your storyboard scene?
Just tried that and it’s doing the same thing. I’m also calling the storyboard.removeAll() on the scene after the level has been unloaded.
Actually purge in a storyboard context just causes createScene() to get re-run the next time the scene is entered. Anything done outside of createScene, like
local thisLevel = require(“level”…thisLevel)
will not be re-executed with a purge. You need to completely remove the scene using storyboard.removeScene() if you have code in the outer part of the module that needs re-executed.
Please watch this video tutorial on the subject…
http://www.coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/
I figured it out…it seems that any package you load into the scene even if it’s local it’s really global. You need to remove the package using the following
package.loaded[“PACKAGE”] = nil
For example
local logic = require(“logic”)
and then when you remove the scene call
package.loaded[“logic”] = nil
What happens when you call
and
in the exitScene() function of your storyboard scene?
Just tried that and it’s doing the same thing. I’m also calling the storyboard.removeAll() on the scene after the level has been unloaded.
Actually purge in a storyboard context just causes createScene() to get re-run the next time the scene is entered. Anything done outside of createScene, like
local thisLevel = require(“level”…thisLevel)
will not be re-executed with a purge. You need to completely remove the scene using storyboard.removeScene() if you have code in the outer part of the module that needs re-executed.
Please watch this video tutorial on the subject…
http://www.coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/
I figured it out…it seems that any package you load into the scene even if it’s local it’s really global. You need to remove the package using the following
package.loaded[“PACKAGE”] = nil
For example
local logic = require(“logic”)
and then when you remove the scene call
package.loaded[“logic”] = nil