Per request, this is an example capx showing how you can do countdowns with text (the 3... 2... 1.. GO! thing).
Of course there are many possible ways to achieve this, this is just a quick example using a private variable as a timer.
there more simple way to create timer, only in two lines of events
thank you guys 4 sharing !! time will come that i`ll give something back to this fantastic community !
this is nice, it should be on the FAQ of the How Do I to help others :)
It is already since it was posted.
Is there a way to make a realtime countdown? like, I want my game to last 2:00 minutes and make it countdown 1:59, 1:58 . . .
Develop games in your browser. Powerful, performant & highly capable.
Sure, that'd be 120 seconds to substract 1 from every second. You can even make the countdown flash, turn red or whatever by comparing remaining seconds (such as countdown < 30). And when it hits zero, the game events are stopped (countdown is < 0). In fact, you can make it so game events are only run when countdown is above 0 seconds (make it the first condition).
Yes, I understand. I was referring to the countdown format, let's say I want my game to last 10 minutes (10:00) then I want it to be displayed as 10:00 not a 600 seconds countdown. Is better explained now jeje?
Use math expressions, such as % (which is modulo):
text.Text = 'Mission time: ' & floor(variable/60) & ':' & variable%60
I haven't checked, but this should display minutes and seconds.
I haven?t tried yet, but thank you very much for the answer :)
[EDIT]: I tried now and it works perfect!!! THANKS :D!!
Hi! After almost 40 minutes I figured out that, for a countdown to work, the variable should be global. Why is that? Why the variable can't be local for this to work?
Because local variables reset every tick.
Either use global or private variables (on objects).
:)) 2 line of events , smartest way to do !! nice, mate !
Hi, thanks for the timer, however how could i repeat it ...as my level resets in 20 secs then it starts counting in - numbers
You just have to reset the counter. In my example, it starts 3 seconds after the layout has started. You can use a different condition and reset the timer, then it'll work anytime you want it to.