How do I make a countdown timer

Get help using Construct 2

Post » Mon Feb 23, 2015 4:54 pm

Hello once again fellas Constructors!

My question has to do with creating a 10:00 and 05:00 countdown timer. I already read the forums but to be honest I'm not so good with the code (as I said in another post) and sometimes looks like... klingon.

The thing is I have already 2 variables, called "10minsTimer" and "5minsTimer" (because the player should select between these 2 options).

You'll see on the screenshot the code I'm using which the timer works nice but I need four digits and everytime I try something like (60,2) I get a syntax error. If I should use zeropad, where should I put it?

Hope we could find a solution, thanks in advance!
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 34
Reputation: 266

Post » Mon Feb 23, 2015 5:35 pm

Hi,

Here is a very simple timer. Essentially it splits out the mins and secs which makes coding it much much simpler, when the seconds run out it knocks of a min and starts again. Hope this is what you meant.
See attached image.
You do not have the required permissions to view the files attached to this post.
B
7
Posts: 61
Reputation: 417

Post » Tue Feb 24, 2015 5:12 pm

Hi Random,

First of all I would like to thank you for a prompt response!

The player should select between a game of 10:00 or 5:00, that's the reason I have 2 global variables "10minsTimer" and "5minsTimer", which I would like to have each countdown working separated. I can follow what you say, but in this case I think it works just for one countdown.

The value of my 10 minutes variable is 600 and 300 for the 5 minutes. Hope this can help a bit more.

Cheers!
B
4
Posts: 34
Reputation: 266

Post » Thu Feb 26, 2015 3:00 pm

Hi,

I see, so you would need a button to select ( in this case I have just used 2 sprites ) and you can use these to set a single time Var to either 5min or 10 min as I do here. This will change and reset each time they choose it. If you only want the timer to start once the level starts you can easy put a delay on the code after they press the button. The only downside is that this timer will just read the numbers it will not put the timer with 0's in it ( for example 01:03 ) it will instead read 1:3. Is this a problem? if so I will look into making read like a 24 hour clock.

Hope this helps a little more let us know if not :)

Regards
Joel
You do not have the required permissions to view the files attached to this post.
B
7
Posts: 61
Reputation: 417

Post » Thu Feb 26, 2015 11:39 pm

Hi Joel,

I really like your method, but unfortunately I would like to have a "01:03" format, as you said. Is there any possibility to apply this to your example by any chance?

Thanks in advance!
B
4
Posts: 34
Reputation: 266

Post » Mon Mar 02, 2015 9:55 am

Bump
B
4
Posts: 34
Reputation: 266

Post » Mon Mar 02, 2015 11:55 am

Indomitus try this demo
You do not have the required permissions to view the files attached to this post.
B
218
S
31
G
14
Posts: 1,890
Reputation: 37,691

Post » Thu Mar 05, 2015 1:39 pm

Hi Lord,

Thanks for your demo!

But it has the same problem that Random and I have. The countdown should be with four zeros, example: 03:09. Because it's showing 3:9, and this case, is not right.

Hope we could find a solution, Cheers!
B
4
Posts: 34
Reputation: 266

Post » Fri Mar 06, 2015 1:12 am

Ok try this

timer.capx
You do not have the required permissions to view the files attached to this post.
Bushy Ball\Boatman Bill\Sticky Web

Image ImageImage

During the gold rush it was a good time to be in the pick and shovel business
B
34
S
8
Posts: 189
Reputation: 4,134

Post » Fri Mar 06, 2015 11:21 am

Perfect, this is what I was looking for! I still need to learn more about global variables, seems like with it I can save more time and space on the code.

Thanks a lot to all of you guys, Siz I owe you one ;)

Cheers!
B
4
Posts: 34
Reputation: 266


Return to How do I....?

Who is online

Users browsing this forum: nutmix and 2 guests