Football game like time

0 favourites
  • 6 posts
From the Asset Store
Time rewind like in "Braid". Choose objects that will be affected by time rewind
  • Hey you guys!

    I ran into a problam and I do need your help.

    As the title says I want to make a Textfield which "holds" the time so it can displays it in a soccer time like way 00:00

    What i got so far is that every second "1" is added to a textfield.

    So that after 2 Minutes 120 is written.

    My problems now are:

    • how do I show the time in the specific format eg. 00:00

    if the program itself is not capable of doing this

    • which is the best plugin to achieve this

    I actually tried alot and came accross a solution which I am not fully able to program.

    I could make 2 textboxes. One holding the Minutes and the other one holding the seconds.

    For the minute box I set: every 60 seconds add 1 to textbox. works out.

    For the seconds box i set: every second add 1 to textbox... BUT now i need to tell the program that if above 59 start again from 0. ... and i cant make it work. I simply dont know where to put the if statement...

    so if someone has a solution or an idea, please share.

    First post first big problem right :-)

    Have a nice day!

  • You were on the right track, no need for plugins here. I made an example for you, hope it helps. Feel free to ask if there's something you don't understand.

    FootballTimer.capx (r95)

    (Edit: Mipey's way is better, check next .capx instead)

  • I have a bad habit called fixing things that ain't broken... Bear with me!

    See system expressions in the manual here


    time - counts time since the game started, includes timescale

    wallclocktime - counts REAL time, no timescale

    zeropad - pads a number with ceros

    Why time or wallclocktime expressions? Because adding dt every tick actually may not be accurate, so I suggest keeping track of the time instead. When you start the counter, add current time to a variable. For countdown, add time + seconds. Then every tick you display variable-time and it shows seconds that passed.

    If you want more precise timing, down to tenths or hundredhs of seconds, you can use the dt counter. Within one second, the inaccuracy is not that big anyway.

    How to display time as minutes and seconds? Easy...

    Set text to zeropad(2,floor(time/60)) & ":" & zeropad(2,time%60)

    The first one shows minutes, padded by leaded zero when needed. Floor is there to ensure it is a whole number.

    The middle one is just there for aestethic purposes. :P

    The last one shows seconds, padded by leading zero.

    I think, at least.

  • zeropad - pads a number with ceros

    Mipey, thanks for mentioning that, was looking for an expression like this, but must have missed it. Will be useful in the future.

    Updated .capx with zeropad: FootballTimer2.capx

    I would use timescale for testing, since it allows the fast forwarding events to check that it all works (without staring at the timer for a minute). Change it to 'wallclocktime' if you want to.

  • Thank you guys very much! The explanation and file were really helpful for me. I even understand it :-).

    But as I tested the difference between "time" and "wallclocktime" I noticed a discrepancy.

    In 2 minutes the time expression actually runs 6 seconds slower than wallclocktime. I don't know if you noticed it.

    Beside that, thank's again :-)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The discrepancy is due to the timescaling. Read about delta-time and framerate independence in this tutorial.

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