How do I make a countdown timer

0 favourites
  • 10 posts
From the Asset Store
Tabata timer
$9.99 USD
Template for Tabata timer, fully documented in comments and video
  • 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!

  • 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.

  • 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!

  • 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

  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Bump

  • Indomitus try this demo

  • 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!

  • Ok try this

    [attachment=0:2xjafzaf][/attachment:2xjafzaf]

  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)