Hello guys, I’m trying to cancel a timer started in a “touch event” function inside another “touch event” function, as shown below:
local function startNewGame(event) if(event.phase=="ended")then local function animationImmaginiOggetti() for i=1, 7 do transition.to( immaginiOggettiAvvioPartita[i], { time=200, delay=0, xScale=0, yScale = 0, alpha = 0} ) end end local function removeImmaginiOggetti() if immaginiOggettiAvvioPartita[1] then for i=1, 11 do immaginiOggettiAvvioPartita[i]:removeSelf() immaginiOggettiAvvioPartita[i] = nil end end end local tmrAIO = timer.performWithDelay(4000, animationImmaginiOggetti, 1) local tmrRIO = timer.performWithDelay(4250, removeImmaginiOggetti, 1) end end local function replayGame(event) if(event.phase=="ended")then timer.cancel(tmrAIO) timer.cancel(tmrRIO) end end startBTN:addEventListener("touch", startNewGame) replayBTN:addEventListener("touch", replayGame)
My problem is that corona returns “File: ? Attempt to index a nil value” on timer.cancel (tmrAIO).
What am I doing wrong?
Thank you,
BR.