Pausing Game

johnccjohncc Member Posts: 25
edited November -1 in Working with GS (Mac)
I have examined the Wiki about pausing the game but am still unsure how to do so. I am fairly new to GameSalad and don't understand alot of the lingo.

Can anyone explain clearly step by step how to pause a game?

(I only have one moving actor)

Thanks!
«1

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Step 1: Create an attributed called Pause
    Step 2: Create a rule in your actor that contains everything you currently have in it. Change the rule to say "attribute game.Pause = 0". Doing this basically says, when the attribute Pause is 0, do everything below. You would need to create a rule like this for every moving actor you have
    Step 3: Create a Pause button. This is just a baisc actor with a touch rule:
    "when actor receives touch"
    Change Attribute game.Pause to (game.Pause+1)%2

    This will make it so when you hit the pause button, game.Pause changes to 1, basically pausing the game. When you hit it again, it changes game.Pause back to 0, allowing everything to move again.

    I just implemented this in my game last night, and I had 30+ moving actors. what a royal pain :)

    I'd throw together a basic project, but I'm at work right now. I'm sure tshirtbooth will do it later on though :)
  • johnccjohncc Member Posts: 25
    Thank you! It finally worked! You are great!
  • venon_itvenon_it Member, PRO Posts: 594
    yessssss, thanksssss for guide, when uploaded a sample project this is the best idea!!

    thanksss
  • venon_itvenon_it Member, PRO Posts: 594
    sorrry, but when i have a game in pause and push a HOME Button iphone, when i re-open the my game ( in iphone ) the game resumes from the pause?

    Thanksss
  • venon_itvenon_it Member, PRO Posts: 594
    ahhh, ok, but in version 1.0 GS it is inserted ??

    you have a solution for this moment?

    Thankss
  • venon_itvenon_it Member, PRO Posts: 594
    ok thankss,

    i have another question, in your example ( pausegame.zip ) you insert a cube rotation, but if i want to insert the cube moves right and left loop?
  • crapscraps Member Posts: 353
    I am trying to work through the pause learning curve. Do I create a "boolean" attribute and name it "pause". Then check the box under value or do I use a different attribute?

    Do I create the pause attribute for the "pause" button?

    The problem I am having is that the "pause" attribute does not show up under the editor -

    change attribute.game.pause

    Thanks
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    you should be able to name any attribute anything you want and it should show up under game in the expression editor.
  • crapscraps Member Posts: 353
    Should attributes be made in the main game window - attributes - that way they show up whenever needed?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    game attributes made in the main window can be accessed in all actors. self attributes made in the window within an actor are only accessible to that actor.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    A pause attribute should be a global game attribute that all the actors in the game should have access to and be able to listen to.

    Click on the Attributes tab above the actor library, and click the [+] to add a new game attribute. Call it something like "gameIsPaused" (without quotes) and make it of type Boolean. Leave it unchecked.

    (Unchecked means false)
  • crapscraps Member Posts: 353
    1. Global attribute made - GameIsPaused-unchecked-boolean
    2. Rule - attribute.game.GameIsPaused...is...false
    3 Under this rule is my animation
    4. Pause button - actor receives event.touch.pressed
    5. Change attribute.game.GameIsPaused TO (game.GameIsPaused+1)%2

    Touching the pause button does nothing.
    Does the +1 change the attribute to TRUE?
    What does the %2 doe?

    Thanks.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    No, (game.GameIsPaused+1)%2 will keep toggling an integer between 0,1,0,1,0,1, etc...

    That uses the modulus [%] math function.

    If you want to use it, you'll need to rebuild your attributes/Rules like this:

    1. Global attribute made - GameIsPaused-Integer-set initially to 0
    2. Rule - attribute.game.GameIsPaused...is...0
    3 Under this rule is my animation
    4. Pause button - actor receives event.touch.pressed
    5. Change attribute.game.GameIsPaused TO (game.GameIsPaused+1)%2

    So instead of looking for true/false you will be checking for 0/1

    0 = false
    1 = true

    If that is too confusing, you can keep it true/false by changing your pause button Rule.

    In pause button, make two nested Rules, like this:

    Rule
    When all conditions are valid
    Actor receives event.touch.pressed
    -----Rule
    -----When all conditions are valid
    -----attribute game.GameIsPaused = false
    ----------Change Attribute game.GameIsPaused To: true
    -----Otherwise
    ----------Change Attribute game.GameIsPaused To: false
  • quantumsheepquantumsheep Member Posts: 8,188
    Let's pause for a sec and try and work out why such a simple fiction has been made so complicated...

    *hic*

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • JGary321JGary321 Member Posts: 1,246
    easy for me =)
  • crapscraps Member Posts: 353
    FireMapleGames -

    I tried everything you told me. But I still have a question or two. Do I type the words true and false in the box following the change attribute?

    ---------Change Attribute game.GameIsPaused To: true
    -----Otherwise
    ----------Change Attribute game.GameIsPaused To: false

    Also do I have to put anything on the animation scene too?
  • iPhoneDevForMeiPhoneDevForMe Member Posts: 362
    When dealing with boolean values (true/false)

    0 = False

    Any number greater than 0 = True

    Simply put,

    Change attribute game.isPaused to 1 to say true. Otherwise 0 for false

    For your case you want to toggle between 1 and 0. To do this use the % symbol.

    So using the expresion editor, add game.isPaused, then type the rest into the expresion editor to get (game.isPaused+1)%2
    and then click the check mark
  • firemaplegamesfiremaplegames Member Posts: 3,211
    @craps: yes, you need to type true and false into the expression editor.

    I'm not sure what you mean by animation scene, but if you mean the Scene window where you drag all your assets, then no, you don't need to put anything there.
  • quantumsheepquantumsheep Member Posts: 8,188
    JGary321 said:
    easy for me =)

    You always say that.

    Nobody likes a showoff. And you know I'm right, anyway ;)

    QS

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • crapscraps Member Posts: 353
    What did I do wrong?

    [IMG]http://i44.tinypic.com/2vb0uol.png[/IMG]
  • crapscraps Member Posts: 353
    What did I do wrong?
  • crapscraps Member Posts: 353
    craps said:
    What did I do wrong?

    http://tinypic.com/r/2vb0uol/5
  • crapscraps Member Posts: 353
    craps said:
    http://tinypic.com/r/2vb0uol/5

    This is under the pause actor and in the game attributes I made a boolean GameIsPaused unchecked box.

    Thanks
  • firemaplegamesfiremaplegames Member Posts: 3,211
    That looks correct to me.

    That should toggle the global game attribute game.GameIsPaused between either true or false.

    Is it not working?
  • crapscraps Member Posts: 353
    No and here is the global attribute

    http://i40.tinypic.com/iwn80z.jpg
  • crapscraps Member Posts: 353
    craps said:
    No and here is the global attribute

    http://i40.tinypic.com/iwn80z.jpg

    I made a pause actor and place the pause png file on it - then applied those rules.

    http://i43.tinypic.com/ojl2c2.png

    Man I must be thick headed.
  • crapscraps Member Posts: 353
  • crapscraps Member Posts: 353
  • firemaplegamesfiremaplegames Member Posts: 3,211
    All your images look correct to me.

    Try this:

    Drag a Display Text behavior into the pause button - outside of those Rules. Instead of "Hello World", change it to display game.GameIsPaused (from the drop-down menu)

    I just tried it here and it works fine. Those Rules successfully toggle that attribute between true and false.

    Let me know if that is working. Does the text change correctly?
  • crapscraps Member Posts: 353
    I cant take it anymore!
    I tried it and no go.

    http://i42.tinypic.com/rkv4f7.png

    From the drop down menu the text does not show up - correct?
Sign In or Register to comment.