Making a traditional timer

This forum is currently in read-only mode.
From the Asset Store
Make your own platformer for both the web and mobile easy with this Santas Platformer Template, FULLY DOCUMENTED
  • Hello again. This one is a small issue, I swear! <img src="smileys/smiley36.gif" border="0" align="middle" />

    I'd like to make a timer which looks more traditional. As in, after 60 seconds, it goes to: "1:00" and so on to show the minutes. I've got the timer aspect of it down. That part was pretty simple, but I can only get it to show seconds. So after it gets to 60 seconds, it doesn't show minutes, it just keeps going up in seconds.

    tl;dr version: I'd like to make a timer which that looks like this: "1:00", not like this: "60". Is there a simple way to do this in Classic?

    Any help would be appreciated. <img src="smileys/smiley1.gif" border="0" align="middle" />

    Edit: Also, I have thought maybe something like this would work:

    Have two separate texts, one would be the minute, and the other seconds. Each seconds reaches 60, I reset seconds, and add 1 to minutes.

    ... I was just hoping there was a more simple was is all.

  • Like this:

    minutes= int(seconds / 60)

    seconds= seconds % 60

    Set Text to minutes & ":" & seconds

  • Well I just tried doing what you suggested, but I think I did it wrong. Here's a printscreen:

    <img src="http://i49.tinypic.com/309jatv.png" border="0" />

    When I untoggle the 'Add 1 every 1000 milliseconds', the text goes haywire when I try to play. When I toggle it as shown in the screencap, it reads: "0:0"

    I feel like I'm missing something obvious here...

  • I feel like I'm missing something obvious here...Yes you are. You're missing a counter of the elapsed time. ROJO showed a way of displaying a value in a minute:second format, but without counting the time it will always read 0:0, of course. Also, don't change the variable that you use for counting. And how come that you were able to enter "int global('Seconds')/60" without an error message? There are brackets missing: "int( global('Seconds')/60 ) "

    First, create a counter for the elapsed time, let's say "totaltime". Now let it count the time:

    +Always

    ->Add TimeDelta to global('totaltime')

    Then add the conversion:

    ->set global 'minutes' to int(global('totaltime') / 60)

    ->set global 'seconds' to global('totaltime') % 60

    and finally show it:

    -> Set text to global('minutes') & ":" & global('seconds')

    Somewhere on these forums you will find my "clock" example, it shows the conversion for h:m:s and also shows how to display the time as an analog clock.

  • > I feel like I'm missing something obvious here...Yes you are. You're missing a counter of the elapsed time. ROJO showed a way of displaying a value in a minute:second format, but without counting the time it will always read 0:0, of course. Also, don't change the variable that you use for counting. And how come that you were able to enter "int global('Seconds')/60" without an error message? There are brackets missing: "int( global('Seconds')/60 ) "

    First, create a counter for the elapsed time, let's say "totaltime". Now let it count the time:

    +Always

    ->Add TimeDelta to global('totaltime')

    Then add the conversion:

    ->set global 'minutes' to int(global('totaltime') / 60)

    ->set global 'seconds' to global('totaltime') % 60

    and finally show it:

    -> Set text to global('minutes') & ":" & global('seconds')

    Somewhere on these forums you will find my "clock" example, it shows the conversion for h:m:s and also shows how to display the time as an analog clock.

    It's now working properly, thanks for the help!

    Also, I'm unsure why "int global('Seconds')/60" worked. I'm using the newest version of Classic, so maybe that's a change that was made?

    I'll look for your analog clock example since that's sort of what I'm going for. Thanks again!

  • I know it can be hard to find especially older caps on this forum. So I had a look at my online database. Here is the analog clock:

    http://www.mediafire.com/file/mkdnhwwzzym/watch.cap

    Don't try to move the window, that functionality is broken, due to changes to the window object. The clock itself works.

  • I know it can be hard to find especially older caps on this forum. So I had a look at my online database. Here is the analog clock:

    http://www.mediafire.com/file/mkdnhwwzzym/watch.cap

    Don't try to move the window, that functionality is broken, due to changes to the window object. The clock itself works.

    Thanks again!

    ... though I'm still confused about how to get that extra zero in there, I should be able to figure it out somehow.

  • ... though I'm still confused about how to get that extra zero in there, I should be able to figure it out somehow. There are various ways to make it.

    For example, just combine two strings and use the expression Right()

    If 'seconds' is a global number variable and 'strSeconds' a global text variable, then

    +some trigger

    -> System: Set 'strSeconds' to Right("00" & 'seconds', 2)

    would first create a string like "001" and then take only the rightmost two letters -> "01"

    Even easier is using ZeroPad():

    +some trigger

    -> System: Set 'strSeconds' to ZeroPad(global('seconds'), 2)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > ... though I'm still confused about how to get that extra zero in there, I should be able to figure it out somehow. There are various ways to make it.

    For example, just combine two strings and use the expression Right()

    If 'seconds' is a global number variable and 'strSeconds' a global text variable, then

    +some trigger

    -> System: Set 'strSeconds' to Right("00" & 'seconds', 2)

    would first create a string like "001" and then take only the rightmost two letters -> "01"

    Even easier is using ZeroPad():

    +some trigger

    -> System: Set 'strSeconds' to ZeroPad(global('seconds'), 2)

    It worked! <img src="smileys/smiley4.gif" border="0" align="middle" />

    Thanks for all the help tulamide. My score system can now fully function thanks to you!

  • Edit: Never mind

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