Restart Button

Ive added a restart button in my game go to back to the “game” story board so the game can be played again, but nothing happens when I click the button.  My “Start” button works and I’ve used pretty much the same code to go to the scene but its not working. Any suggestions?

[lua]function restartGame(event)
if event.phase == “ended” then
storyboard.gotoScene(“game”)
end
end

restart = display.newImageRect(“restart.png”,400,200)
restart.x = display.contentCenterX
restart.y = display.contentCenterY + 300

restart:addEventListener(“touch”,restartGame)[/lua]

Either you can use:

storyboard.reloadScene()

make sure that on reloading remove all listeners and physics, timers, etc.

Or you can use a third class for reference. Like:

  1. In class “game”

    

storyboard.purgeAll()     storyboard.gotoScene("restartGame") --A reference class  
  1. In class “restartGame”

    

storyboard.removeAll()     storyboard.gotoScene("game") --Game class  

Try to use these.

Either you can use:

storyboard.reloadScene()

make sure that on reloading remove all listeners and physics, timers, etc.

Or you can use a third class for reference. Like:

  1. In class “game”

    

storyboard.purgeAll()     storyboard.gotoScene("restartGame") --A reference class  
  1. In class “restartGame”

    

storyboard.removeAll()     storyboard.gotoScene("game") --Game class  

Try to use these.