I am trying to create a countdown timer in Corona SDK that dislays the minutes, seconds and centiseconds left. I have tried the following:
local centiSecondsLeft = 1*6000 + 10*100
local clockText = display.newText("", display.contentCenterX,
display.contentCenterY-100, native.systemFont, 48)
local minutes
local second
local centiSeconds
local function updateTime()
minutes = math.floor(centiSecondsLeft/6000)
seconds = math.floor((centiSecondsLeft-(minutes*6000))/100)
centiSeconds =((centiSecondsLeft-(minutes*6000))%100)
clockText.text = string.format("%02d:%02d:%02d", minutes, seconds, centiSeconds)
centiSecondsLeft = centiSecondsLeft - 1
end
timer.performWithDelay(10, updateTime, centiSecondsLeft)
Although the timer displays the time, a second seems to take more than a second and the timer stops when 1 centisecond is still left. What can I do about it?
Please help.