How do I make a minute and second timer?

0 favourites
  • 11 posts
From the Asset Store
12 looping retro style music tracks for your indie games and projects
  • In another game I'm working on I'm using a minute and second time, but instead of subtracting I need to add to it where it starts at 00:00 and ends at whenever you finish the game.

  • You will need to add variables one for minutes and one for seconds.

    Every tick

    --> add dt (delta-time) to seconds

    If seconds >= (is more or equal) 60 (because there are 60seconds in a minute)

    --> Add 1 to minutes

    --> Subtract 60 from seconds

    And just pack it all in, in a Timer running boolean or whatever you want to stop/start it.

    And if you want it in a text object do:

    Set text to Minutes&floor(Seconds)

  • You will need to add variables one for minutes and one for seconds.

    Every tick

    --> add dt (delta-time) to seconds

    If seconds >= (is more or equal) 60 (because there are 60seconds in a minute)

    --> Add 1 to minutes

    --> Subtract 60 from seconds

    And just pack it all in, in a Timer running boolean or whatever you want to stop/start it.

    And if you want it in a text object do:

    Set text to Minutes&floor(Seconds)

    Could you make some images for this too please? I kinda get deer in headlights at text only.

  • Here is a commented capx.

  • Thanks!

    Edit: Okay I've gotten most of my variables set up, and in the case of the timer starting automatically do I set the variables to constant?

    Edit Edit: Okay I just tried and that didn't work.

  • You need to set local variables to static if not they will reset. (That's how local variables work)

    If you want it to start on the start of layout just do

    On start of layout --> Set Running to 1

  • Okay it's working now. thanks.

    Edit: I've run into another problem...the clock is working okay but in a separate file where I've added the events for the sandwiches and fillings to appear, since I haven't figured out how to set it up so only one sandwich and it's repsective filling pattern appears one at a time the clock stops at 4 seconds. Is this because I have so many sprites on screen?

  • I didn't understand do younwant something to happen after 4seconds?¨

    What do you mean by " sandwiches and fillings "

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • let me redirect you to my other topic:

    basically my clock just froze at 4 seconds.

  • Do you have anything that sets timer running to 0?

  • No I don't.

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