I don’t know how else to explain this so I’ll explain my entire game.
I have 4 scenes:
main.lua
menu.lua
game.lua
gameOver.lua
When main.lua gets loaded it automatically goes to menu.lua. Then you press the start button and you get to game.lua, there appears a text box that displays your score and a text box that displays how much time is left (according to a 60 second timer), when the time runs out a function is ran which goes like this:
function gameOver() scoreText:removeSelf() timerText:removeSelf() timer.cancel(ostaloVremena) saveScore() if(score \> bestScore) then bestScore = score saveBestScore() end if(balloonSpawned == 1) then balloon:removeSelf() end composer.gotoScene("gameOver", "slideLeft", 500) end
Once you get to gameOver scene you have a play again button and two text boxes that display your current score and your high score.
Once you press the button it should take you back to the game.lua scene, and that works but how can I start my timers again and everything else I want to do?
I was thinking to somehow go to that scene and restart it so everything that’s supposed to happen the first time you run it it’s going to happen when you run it from the play again button, but how to do that?
Or to say it this way, I want it to restart the game but not to the point where the splash screen appears and to the main menu, just the game.lua scene.
I hope you understand what I mean, if any code is needed just say and I will put it here. Thanks in advance.