When my timer runs down to 0 the game ends and goes to the restart screen. then when you click restart you can play the game again. the game runs fine if you do this once, but if you do it more than once the count down timer goes negative and doesn’t stop. any suggestions? this is what i got:
[lua]local function timerDown()
timeLimit = timeLimit-1
timeLeft.text = timeLimit
if(timeLimit==0)then
storyboard.purgeAll()
storyboard.gotoScene(“restart”)
end
end
timer.performWithDelay(1000,timerDown,-1)
function shoot(event)
if event.phase == “began” then
bullsEye.x = math.random(0, display.contentWidth - 40)
bullsEye.y = math.random(0, display.contentHeight - 100)
score = score + 1
count = count + 1
scoreText.text = score
if count == 15 then
timeLimit = timeLimit + 5
count = 0
end
end
return true
end
function endGame(event)
if event.phase == “began” then
bullsEye.alpha = 0
timeLimit = nil
storyboard.gotoScene(“restart”)
end
return true
end[/lua]