Question About StopWatch

I’m entirely new to Corona, however, I feel like the problem that I’m encountering should’ve been simple to figure out. Anyway:

I’m wanting to simply create a stopwatch of sorts, so, when I press a button, a time starts counting up. I want this time displayed to be specific to the microsecond. The only thing I’ve found similar to what I want is system.getTimer(), however I can’t seem to bind that to a button (it only calls up time since app started running).

Hopefully my problem is clear and someone can help! Thanks in advance!

Hi @GalesCoGames,

This tutorial may help you on this topic:

http://coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/

Best regards,

Brent

[quote name=“Brent Sorrentino” post=“241278” timestamp=“1397077078”]Hi @GalesCoGames, This tutorial may help you on this topic:   http://coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/   Best regards, Brent[/quote] Thanks for the quick reply Brent! I had found the resource that you’ve linked too, however I’m still not sure how to o about what i need to do exactly. As I’ve said, the system.getTimer() function calls time since the app has ran? And is not able to reference a time since a button was pressed? As for the other functions on the page I’m at a complete loss for how I would utilize them. Sorry for my ignorance. Thanks.

Can’t you just read system.getTime() when the button is pressed, stash that in a variable (startingTime=system.getTime() ), then (in enterFrame?) re-read system.getTime() and subtract out startingTime? 

Hi @GalesCoGames,

This tutorial may help you on this topic:

http://coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/

Best regards,

Brent

[quote name=“Brent Sorrentino” post=“241278” timestamp=“1397077078”]Hi @GalesCoGames, This tutorial may help you on this topic:   http://coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/   Best regards, Brent[/quote] Thanks for the quick reply Brent! I had found the resource that you’ve linked too, however I’m still not sure how to o about what i need to do exactly. As I’ve said, the system.getTimer() function calls time since the app has ran? And is not able to reference a time since a button was pressed? As for the other functions on the page I’m at a complete loss for how I would utilize them. Sorry for my ignorance. Thanks.

Can’t you just read system.getTime() when the button is pressed, stash that in a variable (startingTime=system.getTime() ), then (in enterFrame?) re-read system.getTime() and subtract out startingTime?