Hi Corona Community!
I have a question relating to my basic countdown timer below!
The timer works great! However, I need the timer to restart when it hits ‘0’ seconds.
When it hits ‘0’, it should go back to 15 seconds and should act normally.
All help is appreciated! Thanks in advance!
[lua] --15 second timer for user to submit answers
local timeLimit = 15
local timeLeft = display.newText(""…timeLimit…"’", 280, -20, native.systemFontBold, 30)
timeLeft:setTextColor(0, 0, 0)
timeLeft.alpha = 1
local function timerDown()
timeLimit = timeLimit - 1
timeLeft.text = “”…timeLimit…"’"
if(timeLimit==0)then
print(“out of time”) --out of time
lives = lives - 1
local livesFilename = “lives.text”
saveValue( livesFilename, tostring(lives))
livesText.text = "Lives: "…tostring(lives)
group:insert(livesText)
incorrectSound = audio.loadStream(“Wrong Buzzer.wav”)–incorrect answer sound
audio.play(incorrectSound)–play sound
if (lives == 0) then
timeLeft.alpha = 0
storyboard.gotoScene( “menu” )
end
end
end
timer.performWithDelay(1000, timerDown, timeLimit ) [/lua]