running timer

Hi. Does anyone know.how to make a running timer that will keep counting even when the scene changes? I want to have it where people go to different loss screens based on what time they get. And keep the best time as a record. Thanks everyone

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    @kipdev said:
    Hi. Does anyone know.how to make a running timer that will keep counting even when the scene changes?

    Game.time already does this for you, it's always running in the background.

  • kipdevkipdev Member Posts: 275

    So i just have to display game.time..then reset it when they fail? Thanks

  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2014

    @kipdev said:
    So i just have to display game.time..then reset it when they fail? Thanks

    You cannot reset game.time, it's always running in the background, but you can transfer it to an attribute . . .

    i.e. when player is dead then change game.score to game.time . . . .

  • MoikMoik Member, PRO Posts: 257
    edited November 2014

    @Socks I'm having a similar issue I think.

    1) In the Game Attributes, I have an Integer called GameTimer. I start out with it set to 99999 because it was initially 0 and I was troubleshooting.
    2) In the Main Menu scene, hitting the Play button uses Change Attribute to set GameTimer to 10 (selected, not typed). This is attached to both a Touch and Click constraint, and is the first behavior to occur.
    3) In the Gameplay scene, there is a Timer behavior which says After GameTimer seconds, go to the Game Over scene. I have tried Every and For as well.

    Whenever I preview the game, hitting Play sends me straight to Game Over (the Play Button say Change to Gameplay Scene, not Next Scene or anything). I don't get the expected ten seconds in the Gameplay scene. The loading time is instant.

    I'm trying to have it so the game gives the player 10 seconds to make a decision, and then progressively less time each decision. Like, I want to be able to go GameTimerMax = GameTimerMax - 1 and GameTimer = GameTimerMax as a function off the Buttons, but I'm not seeing the timer take effect.

    What am I doing wrong?

    Turns out it was a problem with an If/Then/Else on an action button.

Sign In or Register to comment.