Pause Mode / Adding a Pause Function / Pausing the Game, Unpausing / Suspend / Unsuspend
This is for any regular sized game that can be exported to PC, Mac and Linux.
Here is a Demo of how Pausing in your game works, select the View Actor to see PAUSE GAME example coding as listed below:
One solution to pause the game and resume it when you're ready by unpausing it, is to have:
1. View/keydown event/script editor: //the reason it's in view is because View is Always present.
2. For the key to enter in the box prompt, enter the letter:
p
//p for pause
Set it for any key pressed, and repeat off. Then go into the script editor.
3. In the script editor, type the following:
PauseGameOn(); //just like that, no need to enter the "game.ged" in the parentheses.
/////////
2. Next, create another key down event within your view, but this one will unpause the game:
View/keydown event/script editor: //the reason it's in view is because View is Always present.
2. For the key to enter in the box prompt, enter any numbers or letters of keys that are used in your game, whether up, down, left, right arrows, w,a,s,d, z,x.... And so on.
w a s d space
//Don't list p here, since the keydown event of p pauses the game when the gamer presses p on the keyboard.
Set it for any key pressed, and repeat off. Then go into the script editor.
3. In the script editor, type the following:
PauseGameOff(); //just like that, no need to enter the "game.ged" in the parentheses.
I'm about to test it myself.
Okay, it works as planned. Just got it working in City of Rott: Streets of Rott.
As a beginner when I first starting learning Game Editor and the C language, I couldn't figure this out because I thought I had to use the same letter to unpause it, so then it was a series of keydown In Order of Buttons Pressed, which went on into infinity because there would be p, pp, ppp, pppp, ppppp, etc, since the player would press the p key countless times to pause and unpause the game.
UPDATE: Feb 2017: Well, after trying out this code in my game which uses timers, I noticed the timers continue to count down even when in pause mode. I have hundreds of timed events going on. I'd have to manually enter EventDisabled commands and then EventEnabled commands to stop and restart the timers.
I wonder what Suspend mode is about.
Moderator's note: Originally posted in "Any way to unsuspend game?", but moved here because the question was resolved long ago, and this post would probably be more useful in the tutorials section.