How To Display and Reset Elapsed Game Time (In Minutes / Seconds)

2
  • 10 favourites

Stats

5,543 visits, 7,927 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Most of us are pretty familiar with the System expression called time

Simply, time stores a value, "The number of seconds since the game started, taking in to account the time scale."

Show the number of seconds the user has been playing

Create an Event, every 1 second

Action: Set Text to time

Show the Minutes and Seconds

Create an Event, every 1 second

Action: Set Text to zeropad(int(time/60% 60), 1) & ":" & zeropad(int(time%60), 2)

Reset the timer when Layout is Started or Restarted

Now comes the hard part. The timer is always counting since the game was launched. How can you restart the counter if the game is restarted?

1) Create a global variable in the layout TimeStartLayout

2) Add the following to the Event sheet

Event: On Start Of Layout

Action: System Set Variable TimeStartLayout to time

3) Whenever you want to use the time since the layout was started or restarted, simply subtract...

Show the number of seconds the user has been playing since start/restart of layout:

Create an Event, every 1 second

Action: Set Text to time-TimeStartLayout

Show the Minutes and Seconds the user has been playing since start/restart of layout:

Create an Event, every 1 second

Action: Set Text to zeropad(int((time-TimeStartLayout)/60% 60), 1) & ":" & zeropad(int((time-TimeStartLayout)%60), 2)

  • 2 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Is there something missing or has it changed in 5 years? Is there a c3p demo to download?

  • "3) Whenever you want to use the time since the layout was started or restarted, simply subtract... "

    Am I reading this wrong or is there more missing to this part of the post cause I feel like there is something missing.