hi, i have a game that show restart button when it’s game over but i dont know how to set up a “restart” function properly. Basically in my game main.lua redirect automatically to menu.lua then if you click “play” button there you will be redirected to game.lua. Here in game.lua i have a restart button with code:
local function restart(event)
if event.phase == "ended" then
onSystemEvent ()
Runtime:removeEventListener("touch", stop )
Runtime:removeEventListener("enterFrame", wrapit)
Runtime:removeEventListener("enterFrame", bucketfollow)
Runtime:removeEventListener("enterFrame", bananacheck)
Runtime:removeEventListener("enterFrame", testCollisions)
Runtime:removeEventListener("system", onSystemEvent )
audio.stop (gameMusicChannel)
director:changeScene ("menu")
end
end
restartBtn:addEventListener('touch', restart)
so basically i add “removeEventListener” one by one before changeScene back to menu.lua. But i believe this is not the best solution because i have to add new “Runtime:removeEventListener” every time i add a new code for different features. How to set it up properly without all these hassles? [import]uid: 114765 topic_id: 23143 reply_id: 323143[/import]
[import]uid: 52491 topic_id: 23143 reply_id: 92713[/import]