Hi, in my app I have a timer that is meant to be paused when the player lost the game.
It works, but when I click on the replay button it disappear (I think it goes on the first layer of the localGroup)
Here’s the code I used:
local function updateScore() score = score + 1 myText.text = secDisplay..score end myTimer = timer.performWithDelay(distance, updateScore, 0) local function move(event) if(rect.x \< 12) then rect.x = 1000 scrollSpeed = 0 waveSpeed = 0 youFlewFor.alpha = 0 myText.alpha = 1 backToMenu.alpha = 1 planePlus = 0 gameOver.alpha = 1 tapToReplay.alpha = 0 pause.alpha = 0 check = 0 timer.pause(myTimer) end end Runtime:addEventListener( "enterFrame", move ) local replay = display.newImage("images/replay.png", 62, 67) replay.x = 16 replay.y = 16 replay.xScale = 0.175 replay.yScale = 0.175 replay:toFront() localGroup:insert(replay) local function reload() director:changeScene("game") end replay:addEventListener("touch", reload)
What’s wrong with it? Thanks in advantage!