Countdown timer to display in hh:mm:ss format
CrumbyEntertainment
Member, PRO Posts: 32
Hey guys so i made a countdown timer and i need it to display the time in the hh:mm:ss format.
I have scoured the forums and numerous example games but none showed what i needed. Say for example the timer was set to 3600 seconds. I would want the timer to read 01:00:00 for one hour. All i need is the functions to insert in the Display Text box.
Thanks in advance for the help.
I have scoured the forums and numerous example games but none showed what i needed. Say for example the timer was set to 3600 seconds. I would want the timer to read 01:00:00 for one hour. All i need is the functions to insert in the Display Text box.
Thanks in advance for the help.
Comments
I have scoured the forums and numerous example games but none showed what i needed. Say for example the timer was set to 3600 seconds. I would want the timer to read 01:00:00 for one hour. All i need is the functions to insert in the Display Text box.
Thanks in advance for the help.
http://forums.gamesalad.com/discussion/comment/434691/#Comment_434691
http://forums.gamesalad.com/discussion/62678/countdown-timer-to-display-in-hh-mm-ss-format#latest
I know that's just a start and doesn't cover every digit, but hopefully you find it helpful.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks.
floor(game.timer1/(60*60))..":"..floor(game.timer1/(60))
mod(game.timer1/(60*60),60)
Mod, also represented as '%', returns the remainder of a division expression. So 3660/3600=1R61 and thus (3660/3600)%60 = 1. That is, two hours and one minute. If you are using custom font digits, you'll have to code each digit. If you are using DisplayText, you can padInt(expression,2) and it will add a leading 0 when there are less than 10 seconds, minutes, hours, etc.
I know I'm cramming in a lot of details but I'm a bit short on time and I'm also building exactly this system for a paying client so I'm not at liberty to share a demo at the moment. Someone else might be generous enough to do so!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
If anyone reading this knows how to do this, and is willing to show me an example I would gladly give due credit to you in the finished app.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
So I actually figured it out and the only problem I have is that it counts fine in the hours position until i get past 9 hours. Once i get to 10 hours it switches to 110 hours..I know it is something to do with the math in the logic but i don't quite know how to approach it. Any help is appreciated, as always!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User