Hi All,
In my current project, I’d like to have a timer that runs on each level of my platformer style game.
Since the game is meant to play fairly fast, I’d like the timer to display 10ths or even 100ths of a second.
Do you recommend that I use a timer.performWithDelay() function to update a timer function or should I create a function that uses an enterFrame listener and does some math with the system.getTimer() function?
I’ve been experimenting with these approaches and have encountered a few weird things. Using a delay of 10 on timer.performWithDelay(), I don’t seem to get the 100ths of a second that I would expect. Eyballing it against my stop watch it seems to run at about half that speed (two seconds to count 100). It’s not a deal breaker if my “seconds” aren’t quite really seconds but it seemed odd.
Also, what would be the best way to get these times to display in a stopwatch style format (mm:ss:th)? Is there a way to concatenate the values with colons at the correct places and display them all as text?
Is there a way to force “0s” onto the front of a number value? If I start at time “0” it just displays as “0” and I need to sort that out as “00:00:00” or “00:00.0”. If I can figure out how to concatenate strings with the correct digits of a number then I guess I can sort the logic on how to make it display a “0” for any missing places.
I’d like to save the last time and best time for each level a player plays. Save values using JSON?
Thanks in advance for any help. I thought this was going to be a straightforward task but I’ve managed to make it much more confusing than I expected 
[import]uid: 105707 topic_id: 36627 reply_id: 336627[/import]