Basically i have a working game , but it only works once . Is it possible to just run each scene like it is it’s first time being run? It’s a basic endless runner game so I really don’t need to save anything . I can run the game one time (menu, game , etc) , and then it just goes crazy lol.
If you are using storyboard you may want to look into storyboard:purgeScene()
Also, be sure to reset any variables that need reseting in the enterScene function.
use enterScene…
What you need to know is that createScene creates everything but only the first time. Then if you go back to the scene Corona will use enterScene.
So there are a couple of solutions to your problem:
-
Put everything in enterScene
-
Purge or Delete the scene
Read these tutorials:
http://www.coronalabs.com/blog/2013/04/02/cleaning-up-display-objects-andlisteners/
http://www.coronalabs.com/blog/2012/07/31/storyboard-scene-purging-vs-removal/ (This bad boy is good)
Purging is removing only the display objects from the scene, to include the scene’s display group (thus freeing up texture memory). However, if the scene is represented by an external module, the module will still remain in memory, as well as any custom variables you attached to the scene object.
Removing a scene means removing everything (display objects, and Lua objects). The result is freed texture memory as well as Lua memory.
Best regards,
Tomas
Reloading scene’s is a complex thing because of the way Lua manages its modules. Storyboard scenes are under the hood, just another Lua module that gets “required” and there are behavioral things you need to understand. It also helps to understand under what conditions createScene gets called and where is the best place to do things. To address this we did a video tutorial on the subject:
http://www.coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/
While it’s for reloading scenes, it’s really good for anyone working with Storyboard to help understand when things happen and where to do certain things.
Rob
If you are using storyboard you may want to look into storyboard:purgeScene()
Also, be sure to reset any variables that need reseting in the enterScene function.
use enterScene…
What you need to know is that createScene creates everything but only the first time. Then if you go back to the scene Corona will use enterScene.
So there are a couple of solutions to your problem:
-
Put everything in enterScene
-
Purge or Delete the scene
Read these tutorials:
http://www.coronalabs.com/blog/2013/04/02/cleaning-up-display-objects-andlisteners/
http://www.coronalabs.com/blog/2012/07/31/storyboard-scene-purging-vs-removal/ (This bad boy is good)
Purging is removing only the display objects from the scene, to include the scene’s display group (thus freeing up texture memory). However, if the scene is represented by an external module, the module will still remain in memory, as well as any custom variables you attached to the scene object.
Removing a scene means removing everything (display objects, and Lua objects). The result is freed texture memory as well as Lua memory.
Best regards,
Tomas
Reloading scene’s is a complex thing because of the way Lua manages its modules. Storyboard scenes are under the hood, just another Lua module that gets “required” and there are behavioral things you need to understand. It also helps to understand under what conditions createScene gets called and where is the best place to do things. To address this we did a video tutorial on the subject:
http://www.coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/
While it’s for reloading scenes, it’s really good for anyone working with Storyboard to help understand when things happen and where to do certain things.
Rob