Hi,
I’ve got a simple timer that begins when I press a button:
local function handleButtonEvent( event )
if ( “ended” == event.phase ) then
local timeLimit = coolDown
timeLeft = display.newText(timeLimit, 120, 80, native.systemFontBold, 14)
timeLeft:setTextColor(255,0,0)
local function timerDown()
timeLimit = timeLimit-1
timeLeft.text = timeLimit
if(timeLimit==0)then
print(“cooldown available”)
end
end
timer.performWithDelay(1000,timerDown,timeLimit)
end
end
coolDown is defined elsewhere, so the code works fine. The problem is that when I press the button AGAIN, it starts a second timer on top of the first one, ad infinitum. Is there a way to also make sure that the button press removes any previous instances of the timer?
Thanks