How do I restart a game in one function ? When the game is over instead of going to a different screen to restart I want to stay on the same page and give the user the opportunity to touch the screen and the game restarts . Can someone help me ?
-- This function stops the game local function endGame() -- Stop the timer timer.cancel(timerHandle) -- Iterate over 'allBalloons' table and destroy all balloons for k,v in pairs( allBalloons ) do display.remove(v) end display.newText( "Game Over", display.contentCenterX, display.contentCenterY, native.systemFont, 40 ) display.newText( "Tap to play again", 150, 300, native.systemFont, 30 ) end
-- Generic/Common enterFrame listener used by each balloon local function enterFrame( self ) -- End the Game if any balloon's CENTER falls below the bottom of the screen if( self.y \>= bottom ) then timer.cancel(timerUpTimer) endGame() end end