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

Stats

3,034 visits, 4,332 views

Translations

This tutorial hasn't been translated.

Tools

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)

  • 1 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • "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.