Time DEMO
firemaplegames
Member Posts: 3,211
Hey,
I made a quick demo showing various ways to work with time in GameSalad:
http://gamesalad.com/game/play/34021
Feel free to use it however you want!
Best,
Joe
I made a quick demo showing various ways to work with time in GameSalad:
http://gamesalad.com/game/play/34021
Feel free to use it however you want!
Best,
Joe
Comments
How can I create a timer (exactly like the raw time) which has two decimal places and can be changed to have 1 and no decimal places?
I have made one before by just making a real attribute and displaying it with a timer rule saying every 0.01 seconds add 0.01 but its a super slow clock. I want it to run at the speed of a clock. Thanks.
i'll try to add it later today.
I'll see about thousandths...
Although, to be honest, I don't think it will be fast enough on an iPhone to realistically capture that...
I'll look into it later.
Joe
If you look at the standard time Actor in the demo, and open its expression editor. you'll see the code for generating the time.( it's a million miles long...)
each chunk of code between each ".." represents a digit in the display.
Here is is broken out onto separate lines:
hours, 1st digit...................floor(floor( game.Time /3600)/10)
hours, 2nd digit..................floor(floor( game.Time /3600)%10)
minutes, 1st digit...............floor(floor(( game.Time /3600)/60)/10)
minutes, 2nd digit..............floor((floor( game.Time %3600)/60)%10)
seconds, 1st digit..............floor(( game.Time %60)/10)
seconds, 2nd digit.............floor( game.Time %10)
tenths of a second............(floor( game.Time *10)%10)
hundredths of a second....floor(floor( game.Time *100)%10)
For what you just asked, just use from minutes, 2nd digit, to the bottom line.
You'll need to use the concatenate operator in between each line to string it all together in the expression editor. The concatenate operator is two periods [..] If you need the colon as well, put that in quotes like this: [..":"..]
instead of updating the timer every 1 second, can you update it every 0.01 second?
I hear what you're saying though, but I don't know the answer. Somebody more mathematical would have to answer it....
and a new attribute called pausedTime.
When you unpause, subtract startPausedTime from game.Time and add it to pausedTime.
Then subtract pausedTime from game.Time when you do your display calculations.
Just thinking out loud here. basically subtract the time the game is paused from the current time to account for that offset.
if you toggle the start/stop button in the demo, it subtracts real numbers from each other.
Here is a little demo showing how to pause/resume a time display...
http://gamesalad.com/game/play/34237
You're trying to make me think on a Sunday!