How to pause the timer, not pause the game?

ElectroFoxElectroFox Member, PRO Posts: 22

Hi folks, I'm still new in GS and this will be my first question. I've searched around and seems like I've done whats told but still didn't work. Alright here it is:

I've followed exactly as TShirtBooth's video tutorial on making Timers. The timer works perfectly as I wanted, no issues on that. Now what I want is that when an actor is pressed, the timer will pause or freeze. I only want the timer to pause, not the whole game (my game won't have a pause option). What I have & tried is this:

Created Game Attributes as per TShirtBooth, which includes My Timer integer & Start Time integer. And all the Rules are according to his tutorial.

Then I read in forums that you have to create a boolean, so I made one and called it Pause Timer. And my rules to attempt the timer to pause is this:

In the Timer Actor, i added rule> if game.Pause Timer is false.
And the Actor i added rule> when touch is Pressed, if game.Pause Timer is true.

That didn't pause the Timer so I'm missing something here, please help. Thanks folks.

Best Answers

  • nickname5862nickname5862 Posts: 51
    Accepted Answer

    I get it, you want to make a countDOWN, well, that is also not that hard at all.

    1. Change the attribute from the begin to 10. I don't mean using a "change attribute" behavior, but changing the attribute in 10, where you created it.
    2. ......Just make it an index attribute, that can't get lower than 0. So, not a "real" one, but "index" one and change that to 10.
    3. Put a "change attribute" attribute right at the same place where one actor tells the game to move on to the next scene. So fight before the "change scene" attribute, place a "change attribute" attribute that tells "timer (the INDEX attribute you have created) to 0"

    All clear?

    (PS: I don't know why, but I don't get your file in your google drive, only the actors (numbered, 1,2,3,4) and the coding in the actors. Is this normal?)

  • tatiangtatiang Posts: 11,949
    Accepted Answer

    Here's the basic idea (game.timer is an integer set to 10; self.paused is a boolean set to false):

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

Answers

  • nickname5862nickname5862 Member Posts: 51

    Few things:
    1. almost everyone here in GS forum, has got an account to a file-sharing service (mine is DropBox). This is smart to do, cause then you only have to put the link here and it will automatically let us see what you have done. You can put your gamesalad file there so we can see what you did and what you did wrong. If you already have this, ok. if not, ask me how if you have questions about this and i'll, i don't know, mail you?
    2. It is easy to stop a timer if you progress further. My way may be somewhat difficult, but I'll try to explain it the best I can:
    https://www.dropbox.com/sh/iwrzazdeeedtxxo/AAD2Jju-MxwjPYx5CC0sYLf2a?dl=0
    I explained everything in notes. Any questions? ask me!

  • nickname5862nickname5862 Member Posts: 51

    By the way... it is "Timer with Button", the other ones were for other examples

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2015

    And the Actor i added rule> when touch is Pressed, if game.Pause Timer is true.

    It should be:

    If Touch is Pressed
    .....Change Attribute game.Pause Timer to true

    If that doesn't work, try adding a Display Text behavior with game.Pause Timer as the expression. Always select attributes from the Attribute Browser drop-down menu instead of typing them in. What does it show for the value of that attribute after you click on the actor?

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

  • ElectroFoxElectroFox Member, PRO Posts: 22

    Thanks for the help both of you, but its still not working after tried what you guys said. This newb has to do something wrong.

    @nickname5862 I thought the (game.button+1)%2 thing should've done the trick but didn't.

    @tatiang tried game.Pause Timer to true but had to manually write True becoz don't see in menu after choosing Change Attribute.

    Alright I have file sharing google drive, heres the link. Its the 2nd scene, the Timer is black circle top right. The actor button is the iPhone 6.

    https://drive.google.com/folderview?id=0Bz8b0PR7vQQrS2xvVS1KWDJXV0U&usp=sharing

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Your Clock actor doesn't have an If Touch is Pressed rule.

    In your L1Q1 Ans1 actor in your Level 1 Q1 scene, you still have If Touch is Pressed AND game.PauseTimer is true but no behaviors inside of that rule to actually pause the timer.

    By the way, it's much easier to build a quiz game in a single scene and use tables to store all of the information including questions, answers, and image filenames.

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

  • ElectroFoxElectroFox Member, PRO Posts: 22
    edited March 2015

    The Clock actor doesn't have If Touch rule becoz Clock not supposed to be touched, but anyhow I've added a rule now.

    The L1Q1 Ans1 actor behavior left it blank becoz I don't know what to put. okay I've put the rule into it now as per @nickname5862 , but still Timer not freezing.

    Alright I will learn about the Tables to make my game, in the meantime I must make the timer freeze (not giving up yet). Please help, appreciate it.

    https://drive.google.com/folderview?id=0Bz8b0PR7vQQreENvbXN0dVlTS00&usp=sharing

  • nickname5862nickname5862 Member Posts: 51

    So, if I understand, my project works. You copied exactly what I have done, and it does not work anymore. For some reason, I don't get the whole file when I click your link, only a lot of coding.
    What I ALWAYS do if I get stuck somewhere in the middle: Start over.
    I know you will be thinking "he has gone nuts" but no, star over in a new project and try to make this thing work. Just, when pressed, "attribute" to false. If true, every 0,1 seconds "another attribute" to "another attribute+0,1"
    I don't really understand what is so hard about this. Are you stuck on a specific place? What does the timer show you when you do it? UF nothing else works, start over OR try "Log debugging statement". This way you can put it everywhere and see where it goes wrong.

  • ElectroFoxElectroFox Member, PRO Posts: 22

    @nickname5862 said:
    So, if I understand, my project works. You copied exactly what I have done, and it does not work anymore. For some reason, I don't get the whole file when I click your link, only a lot of coding.
    What I ALWAYS do if I get stuck somewhere in the middle: Start over.
    I know you will be thinking "he has gone nuts" but no, star over in a new project and try to make this thing work. Just, when pressed, "attribute" to false. If true, every 0,1 seconds "another attribute" to "another attribute+0,1"
    I don't really understand what is so hard about this. Are you stuck on a specific place? What does the timer show you when you do it? UF nothing else works, start over OR try "Log debugging statement". This way you can put it everywhere and see where it goes wrong.

    Okay, what I did was checked your file and the Timer did pause. So I **only **copied the rules under the When press space - change attribute game.button.... (but use my game attributes). Now in my project, the timer basically keeps counting down & won't pause.
    I didn't copy every single thing becoz the timer on your file have endless decimals & looks out of place (I understand you made it just to show me its a timer).

    Alright, I'll start over and follow your template carefully. Get back to you when done, and appreciate it bro.

  • nickname5862nickname5862 Member Posts: 51

    If nothing works and you really can't figure it out, I will try to find your problem if you want to. I also have got a file where there must be something wrong, but I just can't find it. You can always come to me bro!

  • ElectroFoxElectroFox Member, PRO Posts: 22

    As expected, following the template does pause the timer (i've managed to remove decimal and made it countdown from 0) but problem is i want the timer to be as per my original project. Apologies if I didn't clarify it from the beginning, so to sum it up what i need help is this:

    1. The timer now countdown starting from 0, how can I make it to countdown say start from 10 seconds?

    2. When countdown reaches 0, i want it to stop there and doesn't go beyond.

    3. Countdown should start over when move on to the next scene.

    Heres the latest file. Thanks again, appreciate it.

    https://drive.google.com/file/d/0Bz8b0PR7vQQrcndUakpqdWpKT2M/view?usp=sharing

  • ElectroFoxElectroFox Member, PRO Posts: 22
    1. The countdown from 10 seconds works now.
    2. There is no option to choose "index". (checked the forums, they say Windows version don't have it)
    3. Since I can't create index, so tried integer instead and "change attribute" to 0 to the actor as mentioned. Result is it shows 0 and nothing else happens.

    (PS: my file doesn't appear that way, that's weird. But I do get an small error message when tried to save)

    Okay I'll start over again and figure something out. Thanks for the help anyway, appreciate it.

  • ElectroFoxElectroFox Member, PRO Posts: 22

    Alright finally I got it to work. With both of your help and some additional info searched around the forum, now I got exactly what I wanted. Thanks guys & take it easy.

  • nickname5862nickname5862 Member Posts: 51

    Don't forget to choose your "best answer".
    Without it, this forum is not closed yet and will still be open...

    ...I think

    (pick me, pick me!)

Sign In or Register to comment.