How can make a count up timer that shows Hours, Minutes, Seconds & Milliseconds?
it would be in this format of two digits each 00:00:00:00 or maybe 00:00:00:0 with just one digit for the milliseconds
I'm making a simple puzzle game and I would like to time how long or fast it took to solve the puzzle.
Best Answers
-
Socks London, UK.Posts: 12,822
padInt( game.Clock.Hour ,2)..":"..padInt( game.Clock.Minute ,2)..":"..padInt( game.Clock.Second ,2)..":"..padInt(round( game.Clock.Millisecond /10),2)
-
tintran Posts: 453
You can use the game.Time or self.Time(actor variable) to get number of seconds have passed, and then do your own math, to figure out hours,minutes,seconds,milliseconds
like
to get hours: padInt(floor(game.Time/3600),2)
to get minutes: padInt(floor((game.Time%3600)/60),2)
to get seconds: padInt(floor(game.Time%60),2)
to get hundredths of seconds: padInt(floor(game.Time*100%100),2)then you can join them all together using ..":"..
the .. just joins strings together. and the colon (:) is in quotes for the whole thing to work.
If you want to set your own start_time to save game.Time or self.Time then when the puzzle is solved you can set your own end_time to save game.Time or self.Time..
and subtract start_time from end_time should give you number of seconds that took to solve the puzzle and you can use this number of seconds in the above padInt calls instead of game.Time.
Hope that helps.I took too long to replied and got ninja'd by both of you hehe
Socks is king
Answers
it sez Invalid Expression, lol
Can you upload a screenshot of the expression.
Just kidding, I got it, thanks again Sir!
Socks is not just King but also the Queen, lol
Are you saying that Socks is female gender?
Next question is.... I want the time to be the final score to show who's the fastest. will the strings inside the Display Text be saved to submit in the leaderboards?
hahahaha
Saved to what or to where ?
as the final score that can be posted to the leaderboards
How can i save this timer to show when finish my game