How do I Make A countdown timer?

Get help using Construct 2

Post » Tue Apr 15, 2014 8:25 pm

How do I Make A countdown timer? I want to have a clock that counts down form 24 hours by the second. So something like this: 24.00.00 => 23.59.59 => 23.59.58 and so on. How to do this?
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Post » Tue Apr 15, 2014 9:29 pm

Like the other thread. YOu will need to either use a an unoffical plugin. Which you can find in the plugins section of the forum.

Or you can learn some js and use the Browser.jsexec capabilities. C2 has no realtime clock functionality as of yet.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Wed Apr 16, 2014 2:00 pm

Hi! I am looking for somthing similar.
I installed the System Time Plugin (viewtopic.php?t=63492&start=0) and I want to show a custom countdown.
The User has 3 input fields. One for Days, Hours and Minutes. So if you enter 1 Day, 12 Hours it should display a Countdown counting down the entered amount of time.
But it should work even if you close the app for a while and reopen it a few hours later (thats why you need the plugin).

So if you launch a timer you need to get the current system time (I used the unix format) and then add the entered Amount of time and store it. And every x Seconds (or whenever you want to refresh your countdown timer) it should show the remaining time. Did anyone already create something like this or know a good/easy way to do this?
B
54
S
16
G
6
Posts: 719
Reputation: 9,207

Post » Wed Apr 16, 2014 2:11 pm

I just tried a few things with the system time and it seems to work if you just subtract the destination time (current+entered amount for the countdown) from the current system time.

The code:
Image
It displays a 5 Minute countdown counting down every second.

/Update: Seems it does not work as expected. I added 10.000 to CurrentUnixTime (should be 10 seconds when the Unix Time is in Milliseconds?) but my Countdown shows an additional hour and adding 1 day shows 0 instead of 24 hours (only uses 0-24 for a single day and cant display more like 36 hours?) :?
Any ideas how to fix this?
B
54
S
16
G
6
Posts: 719
Reputation: 9,207

Post » Wed Apr 16, 2014 6:20 pm

I have downloaded the plugin but have yet to incorporate it and try it. Just wanted to thank you for posting the URL! It looks very helpful :)
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Post » Wed Apr 16, 2014 9:53 pm

Simply have a global variable called 'timer' at a default 86400 (the seconds in a day) then an event being:

System-every second- -subtract 1 from 'timer'

Hope that helps.
B
15
S
5
Posts: 18
Reputation: 1,131

Post » Wed Apr 16, 2014 10:09 pm

HZGaming wrote:How do I Make A countdown timer? I want to have a clock that counts down form 24 hours by the second. So something like this: 24.00.00 => 23.59.59 => 23.59.58 and so on. How to do this?


See the attached example.

@Bl4ckSh33p: It looks actually like a completely different subject, you should start your own topic on the issue, or maybe even seek help in the plugin's topic, in case.
You do not have the required permissions to view the files attached to this post.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,293

Post » Sun Apr 20, 2014 6:11 am

Thank you very much for your example @Kyatric. It's working now. :)
Maybe I should not try to code when I need to take strong antibiotics. It sometimes makes your brain silly. ;)
B
54
S
16
G
6
Posts: 719
Reputation: 9,207


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, namaewayukidesu, senecaa and 10 guests