[SOLVED] Help how to have millisecondswhen using a timer?

Hi

Is it possible to have milliseconds? What I need help is I’m creating is tracking how fast someone can react soemthing, and to get accurate data I need the timer to have milliseconds. So basically after the second mark it should have two more digits that count fast up to 99 to reach 1 second representing milliseconds. [import]uid: 17058 topic_id: 31178 reply_id: 331178[/import]

What you’re actually asking for is hundredths of a second, milliseconds are what Corona works in anyway i.e. 1000 milliseconds to a second.

I haven’t tested this as I’m at work but it should give you an idea:

[lua]local minutes = 0
local seconds = 0
local hundredths = 0
local clockTimer = system.getTimer()

local timeText = display.newText(“0:00:00”, 160, 240, system.defaultFont, 20)
localGroup:insert(timeText)
local gameLoop = function (event)

local t = system.getTimer()
local elapsed = t - clockTimer

minutes = math.floor(elapsed/60000)

local remainder = elapsed - (minutes * 60000)
seconds = math.floor(remainder/1000)

remainder = remainder - (seconds * 1000)
hundredths = math.floor(remainder/10)

local minText = minutes
local secText = seconds
local hunText = hundredths

if seconds < 10 then secText= “0”…secText; end
if hundredths < 10 then hunText =“0”…hunText; end

timeText.text = minText…":"…secText…":"…hunText

end
Runtime:addEventListener(“enterFrame”,gameLoop)[/lua] [import]uid: 93133 topic_id: 31178 reply_id: 124688[/import]

What you’re actually asking for is hundredths of a second, milliseconds are what Corona works in anyway i.e. 1000 milliseconds to a second.

I haven’t tested this as I’m at work but it should give you an idea:

[lua]local minutes = 0
local seconds = 0
local hundredths = 0
local clockTimer = system.getTimer()

local timeText = display.newText(“0:00:00”, 160, 240, system.defaultFont, 20)
localGroup:insert(timeText)
local gameLoop = function (event)

local t = system.getTimer()
local elapsed = t - clockTimer

minutes = math.floor(elapsed/60000)

local remainder = elapsed - (minutes * 60000)
seconds = math.floor(remainder/1000)

remainder = remainder - (seconds * 1000)
hundredths = math.floor(remainder/10)

local minText = minutes
local secText = seconds
local hunText = hundredths

if seconds < 10 then secText= “0”…secText; end
if hundredths < 10 then hunText =“0”…hunText; end

timeText.text = minText…":"…secText…":"…hunText

end
Runtime:addEventListener(“enterFrame”,gameLoop)[/lua] [import]uid: 93133 topic_id: 31178 reply_id: 124688[/import]

Yes exactly like that thanks so much. I was just able to see this code last night and test it. I been really busy that why I had not posted soon. But anyways thanks for the help [import]uid: 17058 topic_id: 31178 reply_id: 125906[/import]

Yes exactly like that thanks so much. I was just able to see this code last night and test it. I been really busy that why I had not posted soon. But anyways thanks for the help [import]uid: 17058 topic_id: 31178 reply_id: 125906[/import]