Reputation: 21
Currently I am trying to make a simple game Using corona simulator. After the game is finished I want to incorporate a replay button. So far the button restart the game but I am unable to "reset the environment/clean up the memory/clear previous values of the variables". Looking for some guide from the expert.
Upvotes: 1
Views: 846
Reputation: 454
Look at the Corona Composer. It's the recommended way to develop in Corona and (IMO) very simple and effective. It handles the complicated stuff such as memory management and garbage collection for you.
In your case, you would create a scene for your game, and then you could reload that scene and as long as you've stuck to the guidelines, it will handle rubbish collection for you. As for how to most efficiently reload a scene, try this
Upvotes: 0
Reputation: 28950
I guess the nice approach to this would be to avoid using global variables for your game state so garbage collect would clean up once your local stuff got out of focus.
Another way would be to clean up table _G
where Lua stores its globals.
Upvotes: 2