Pause Tutorial

JGary321JGary321 Member Posts: 1,246
edited November -1 in Working with GS (Mac)
The community here has helped me with many problems. I figured I would give back by doing a tutorial on how to implement a "Pause" system. This is how I did mine. I am sure there are many ways of doing it. To alot of people all this may be common sense, but I'm sure some will find it helpful. I am not a pro at writing a tutorial, so bear with me. Also I am at work, so I am going by memory. Also if anyone has questions about setting up a Pause system, please ask them hear. Maybe we can get something similar up on the "How-To" Wiki...

Without Furtherado::

First thing you need to do is set a "Boolean" Game Attribute. I called mine "Game Paused". I have it set to 1 (so the game starts paused).

Second for each moveable actor you have to setup a Pause Rule. This is done wherever you have the Move command on the actor. For example, I have it so my enemy mobs randomly choose a location to move to toward my castle. I place that "Move-To" command within a rule that states (actor attribute changed, game.Game Paused = FALSE). If you have an animation for the actor that also goes under that rule.

What this does is that if the game attribute Game Paused = 0(false) then the actor moves/animates as normal. Otherwise it stands still.

You basically do this for every actor that can be changed. For instance I have a game attribute called Game Time. My Game Time starts at 30 secs & I used a timer that says every 1 second that game.Game Time = game.Game Time -1. (this deducts 1 second every 1 second) I put that timer under a rule that says (actor attribute changed, game.Game Paused = FALSE). So essentially the Timer only works if game is not paused.

I also made a text box that shows the Game Paused=True, that says "Game Paused". I made a second by right under that that says "Tap to Continue". I created an attribute that says when the text box is tapped to changed game.Game Paused-False. (this unpauses the game)

Bah, that stupid text box is still there! That's easy let's Destroy it after the game is unpaused.... Not a good idea. I guess technically you could destroy/respawn when it is un paused, but i took the easy way out. See that Otherwise part of your Rule? The one that most people don't ever use?? Well I created another text box. In the text box I put a "." & then made is translucent, so you can't see it. Less work on my part, but you can do it either way.

You can now also setup a button that if game.Game Paused = 0, change attribute game.Game Paused = 1. You don't need to setup then pushing the button again, b/c we already set that up in the text box.

That completes my tutorial, I know it's probably not the best written, but hopefully it will help someone. I plan on creating more tutorials on different things, if everyone likes this one, (& if it's ok with the moderators). Thanks guys for the support you have shown me, hopefully this helps in some way.

-JGary

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Hi JGary321,
    If you want, you can add this to the wiki how-tos.
  • quantumsheepquantumsheep Member Posts: 8,188
    Thanks JGary321, that's a very interesting read, and could be really helpful to people.

    I was thinking of something along the same lines but for a sound on/off function!

    Would be very interested in reading more!

    Thanks again! :)

    QS

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

  • JGary321JGary321 Member Posts: 1,246
    Bah, I just noticed that the tutorial was larger than supposed to be. I was writing it in google docs & I double pasted. Sorry. Can't edit now.

    Also, went ahead & threw this up on the tutorial wiki.
  • ktfrightktfright Member Posts: 964
    nice, do work man!!!
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Thanks JGary. I gave it a title header and added the link to the how-to page. Also removed the duplicate page.

    http://gamesalad.com/wiki/game_pause_tutorial
  • JGary321JGary321 Member Posts: 1,246
    Ok, thanks for the edit.
  • ktfrightktfright Member Posts: 964
    mybad JGary, im acting so N00B today, but with your pause tutorial, could this apply to an accelerating actor like my car, because i see on your tutorial that it applies to actors that have "move" or "move to" attributes
  • JGary321JGary321 Member Posts: 1,246
    yup, you know where your rule is for accelerating? For instance, If key pressed = up accelerate 90, or something to that effect. Well make it something like

    If key pressed = up
    If game.pause = 0

    Then accelerate...etc...

    Now the one thing I 'don't know is how well it will resume. Like if the car will start back over at speed 0 or what. So lemme know how it turns out.
  • alias_noaalias_noa Member Posts: 19
    So you mean you just change the "moveable" boolean to false when the game is paused? Because I tried that and it just doesn't seem to work.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    That's not what they are saying at all. Moveable cannot be modified during runtime. They are putting all of the move/move to behaviors in a rule that requires game.paused to be false. When game/paused is true, no movement would happen.
  • AfterBurnettAfterBurnett Member Posts: 3,474
    So this works with timers too? All of my enemies are spawned with timers... I wonder if I could get this to work... hmmm...
  • JGary321JGary321 Member Posts: 1,246
    @Poly - Pause works with timers. Just need an extra step to do it. You need to create an integer called timer in your actor.

    Your timer rule would be

    If game.paused = false then Every 1 sec self.timer = self.timer-1.

    The spawn rule would be
    When self.timer = 0 then spawn actor & change attribute self.timer = (whatever the initial spawn time is)

    Make sense??
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Yeah... MIGHT be able to get it working. It's a VERY fast paced shooter with rules such as "for 10 seconds, every 0.7 secs spawn enemy x). Could be tricky.
  • JGary321JGary321 Member Posts: 1,246
    With something like that you just need:

    If self.timer > 0 & game.pause = false then every .7 secs spawn enemy.
  • AfterBurnettAfterBurnett Member Posts: 3,474
    AH okay, cool! I'll implement it in an update. Thanks heaps!
Sign In or Register to comment.