How to pause a timer?

thomasrichardgamesthomasrichardgames Member Posts: 263
edited August 2012 in Working with GS (Mac)
I have a timer that counts down, but i want the timer to pause when the pause button is pressed. (when the pause button is pressed, it spawns an actor). I don't want anything else to pause, just the timer? How would i go around doing this. Thanks. :)

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Create a boolean attribute called Paused.

    In your timer:

    Wrap your timer rules etc in a rule that says:
    When attribute game. Paused is false.


    In your pause actor:
    When touched is pressed:
    Change attribute game.Paused to true.


    Hope this helps.

  • MarcoColMarcoCol Member, PRO Posts: 279
    Hi,

    I have just the same problem. I do a timer as in the example of the TShirtBooth-Video.
    So then I wrap in my timer all in the rule and put it "When attribute game. Paused is false".
    On my pause-button I put then when it will be pressed, that the change attribute game.paused to true.
    In my pause-scene (I have no pause-actor but a pause-scene) I put then in the button to go back to the game the change attribute game.paused to false.

    So the result is that the timer starts, when the game starts.
    If I put the pause-button, then the timer will not be seen through the 50% transparent-pause-Scene, but ok. When getting then back to the game by pressing the back-to-game button, then the Timer start again at 60 seconds (my timer counts all the time in the level from 60 back to 0).

    What must I change there?
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    That will only mean the 'counter' that you have is resetted everytime. By the way how are you making that counter? Integer attribute counter = counter - 1 every 1 sec?
  • MarcoColMarcoCol Member, PRO Posts: 279
    I use the method, descibed in this video:


    How can I pause the timer, when I change my game-status in the pause-mode (clicking the pause button, change the scene, pause game)?
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    To my knowledge i think the pause game function doesn't pause the internal clock.
    Maybe some expert can verify that.
  • MarcoColMarcoCol Member, PRO Posts: 279
    Ah, that sounds logical! So then I can't use the internal clock...
    I'll try your suggestion:
    Integer attribute counter = counter - 1 every 1 sec
  • MarcoColMarcoCol Member, PRO Posts: 279
    I've change it that change attribute as "REAL" every second = attribute -1 and it works.
    Is there a problem using REAL instead of INTEGER?
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    no unless you have decimals value. but i doubt there will be.
  • MarcoColMarcoCol Member, PRO Posts: 279
    My counter simple counts from 90 to 0 and then it ends. So no decimals?!
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    edited October 2012
    no problem.
Sign In or Register to comment.