I am making a game where:
main.lua sends you to menu.lua
from menu.lua you can go to levelselect.lua
from levelselect.lua you can go to level1.lua
from level1.lua you can either go back to menu.lua or restart level1.lua
However I am having various problems. The first time you run the game, it works fine, everything happens once and the variables are all correct, however if you try to go from level1.lua to menu.lua, weird things start to happen. Everything happens multiple times. I made each “enterScene” function print “entered” to the console and this prints 6 or 7 times.
Also, when you get to the game, the variable goes from 5 to 1 right when you start. Also the physics body, which is a ball with no gravity, randomly moves around as if it is bouncing off things that aren’t there. It changes its speed even though its not supposed to.
I know about the standard storyboard template and that was helpful, but it wasn’t complete. I need a template that is of an actual game (it doesn’t have to be complex) which can go from scene to scene without weird things happenning.
FYI: every scene, after it exits, removes itself, and the destroyScene removes all display objects and sets all variables to nil. Also, physics is enabled.
Attached is my whole project so far with the menu, level select, and level 1. If you want to see the code, look at it.