Hi guys, I have a game I am making and i have a retry button. When I click the retry button, it goes to a restart.lua and then back to game.lua
This works fine the first time, however the second time, the player moves at twice the speed with 2 player images. 1 stays still and the other flys fast. Then every restart after that doubles the speed of the player.
This function is called when the try again button is pressed
function tryAgain(event, stage) if(event.phase == "ended")then storyboard.gotoScene("restart",{time=200,effect="fade", params={}}) end end
Then this is whats in the restart.lua file
local storyboard = require "storyboard" local scene = storyboard.newScene() function scene:enterScene(event) storyboard.removeAll() local function removeOld() storyboard.gotoScene("game",{effect="fade",time=500}) end timer.performWithDelay(100,removeOld,1) end scene:addEventListener("enterScene",scene) return scene
With using remove all, I do not understand why its not deleting the scene and starting afresh.
EDIT: I have found out that the main loop is running twice on those times it errors. I need to somehow remove the main loop.
The main loop works the normal way.
local function main( event ) --super secret code end Runtime:addEventListener( "enterFrame", main)
I do also have this bit in there too
function scene:destroyScene(e) Runtime.\_functionListeners = nil allPlatforms = {} end scene:addEventListener("destroyScene",scene)