5 min Countdown timer doesn´t stop at zero
FamTechAdmin
Member Posts: 47
Hi.
I'm have a countdown timer that starts at 05:00 and should stop at 00:00. I created the timer with the help of two tutorials that I found on YouTube...
...But I encountered two minor issues that I don´t know how to solve.
First, you hardly see 05:00 when the timer starts. you see it for a millisecond before it goes to 04:59. Is there a way to "delay" it so that you can actually see the 05:00, before it starts the countdown?
Second, the logic below should stop at 00:00, according to one of the tutorials but when I preview it, it just goes past 00:00 and stops instead at 59:59.
Attributes
StartTime 0 real
MyTimer 0 real
Display Text
- floor(floor(( game.MyTimer %3600)/60)/10)..floor((floor( game.MyTimer %3600)/60)%10)..":"..floor(( game.MyTimer %60)/10)..floor( game.MyTimer %10)
Change Attribute
- game.StartTime to game.Time
Rule
- When all conditions are valid, game.MyTimer to > 0
- Constrain Attribut_e
- _game.MyTimer to 300-( game.Time - game.StartTime )
Comments
i made this template over a year ago so I'm not to sure if this is what your after as i haven't opened it since. but give it a check.
http://www.gsinvention.com/store/p49/Count_Down_Timer.html
GSINVENTION FREE TEMPLATES
@CodeMonster thanks.
I downloaded the rar file, but it doesn´t open in game salad. the .gsproj is 0 bytes for some reason. I extracted the files 3 times and and downloaded the the rar 2 times
Seems like you should just be able to use a if true/if false boolean.
Make an attribute Boolean called TimerMoving... then put it on a rule over timer which will be like: If TimerMoving is true then (Timer)
@FamTechAdmin oh sorry to hear, ill make an updated version now, to see if it helps, give me a sec.
GSINVENTION FREE TEMPLATES
@FINNBOGG @yasoofx
thanks for the tip... I found the bug.
@CodeMonster no need, I found what was causing the problem
I solved it by doing it like this
Display Text
//I added the change attribute below and a timer for the countdown
Change Attribute
Timer
Rule
then I also changed the rule, that I now realize that I forgot to mention in beginning (sorry about that), so that the timer should stop at 00:00.
Rule