How can Timer run in background?

T0bsomT0bsom Member Posts: 9
edited April 2013 in Working with GS (Mac)
How can I run a timer so count how much you have played in the game. The timer will only count the game scenes and not pause scene or menu scene, but will only be displayed in the pause scene. The timer will run in background. How can I do that?

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2013
    If by background you mean while the app is not running or not the foreground app then see this: https://forums.gamesalad.com/discussion/55578.

    If you just want a timer that runs in-game while the app is active then you need to make your own timer:

    When game.paused (boolean) is false
    .....Timer every 0.1 seconds
    ..........Change Attribute game.elapsedTime (real) to game.elapsedTime+0.1

    Then, whenever you switch to a pause or menu scene, set game.paused to true and whenever you switch to a game scene, set game.paused to false.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.