Pausing Game
johncc
Member Posts: 25
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!
Can anyone explain clearly step by step how to pause a game?
(I only have one moving actor)
Thanks!
Comments
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
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
thanksss
Thanksss
you have a solution for this moment?
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?
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
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)
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.
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
*hic*
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
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?
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
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.
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
[IMG]http://i44.tinypic.com/2vb0uol.png[/IMG]
Thanks
That should toggle the global game attribute game.GameIsPaused between either true or false.
Is it not working?
http://i40.tinypic.com/iwn80z.jpg
http://i43.tinypic.com/ojl2c2.png
Man I must be thick headed.
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?
I tried it and no go.
http://i42.tinypic.com/rkv4f7.png
From the drop down menu the text does not show up - correct?