Page 1 of 2
Pausing the game
Posted:
Thu Jul 26, 2007 3:29 pm
by arcreamer
can someone show me how to pause the game by pressing P for pause to create a pause actor and pressing P to unpause?
Posted:
Thu Jul 26, 2007 4:30 pm
by Sgt. Sparky
I made a simple pause example demo:
http://game-editor.com/forum/tp-3676-15 ... tors-.html
(it does not use the built in pause function because that makes everything stop.
)
Posted:
Thu Jul 26, 2007 6:23 pm
by arcreamer
i already looked at that earlier and its waaaay too complicated i dont understand any of the script and when i use it on mine it messes up =(
Posted:
Thu Jul 26, 2007 11:08 pm
by pixelpoop
These directions will allow the pause of all the actors and animations. The only thing you can do in this pause state is un-pause. If you need a pause menu then you should try and figure out Sgt. Sparky's pause method.
on the view actor put a key down event.
add the key p by pressing p
change Repeat: to Disable
Add Action-> Script Editor
create a variable called gamePaused
Put this in the Script Editor
if(gamePaused == 0)
{
PauseGameOn();
gamePaused = 1;
}
else
{
PauseGameOff();
gamePaused = 0;
}
Posted:
Thu Jul 26, 2007 11:16 pm
by arcreamer
when i put that code in it says "Error line 1: Undeclared identifier gamePaused
Warning line 1: possible non relational operation
Error line 1: undefined type for relational program
Error line 4: Incompatible types: cannot convert from 'const int' to 'Identifier'
Error line 9: Incompatible types: cannnot convert 'const int' to 'Identifier' "
what do i do?
Posted:
Thu Jul 26, 2007 11:17 pm
by arcreamer
nvm i added a variable called gamePaused and got it all working thanks!
Posted:
Thu Jul 26, 2007 11:43 pm
by pixelpoop
I update my first post with:
create a variable called gamePaused
Posted:
Fri Jul 27, 2007 2:06 am
by arcreamer
I got it; thanks!
Posted:
Fri Jul 27, 2007 2:45 am
by Fuzzy
in views draw event..
- Code: Select all
while(Pause == 1)
{
if (getLastKey() == KEY_p)
{
Pause = !Pause;
}
}
Posted:
Fri Jul 27, 2007 12:57 pm
by makslane
This while will lock your game.
Just check the key, or, better, put the check in a Key Down event.
Posted:
Fri Jul 27, 2007 11:50 pm
by DilloDude
A way I often use is to have a variable, paused (or unpaused). At the beginning of each actor's draw actor script, check that the game is unpaused. If not, then do a list of things such as setting velocity to 0 and other requirements. It depends what the actor does.
Posted:
Sat Jul 28, 2007 12:49 am
by arcreamer
how do i make so that when pause is activated, it creates an actor that says Pause which i already have ready i just dont know how to make it appear when i press pause and wherever my character is... can someone help me?
Posted:
Sat Jul 28, 2007 7:19 am
by pixelpoop
when using the GE PauseGameOn function everything becomes frozen, scripts don't run. The only way to unfreeze is with PauseGameOff.
If you want to have some stuff not frozen during a pause you need to create your own pause variable and have every script of every actor that will freeze check for this variable before it executes. So every script would look something like this:
if (my_pause_variable==0){
all your normal code
}
Their is more to it then this if you are using things like velocities.
Posted:
Sat Jul 28, 2007 7:25 am
by pixelpoop
arcreamer wrote:how do i make so that when pause is activated, it creates an actor that says Pause which i already have ready i just dont know how to make it appear when i press pause and wherever my character is... can someone help me?
I think if you put on the create actor event of the pause graphic PauseGameOn(); it should pause.
Posted:
Sat Jul 28, 2007 9:57 am
by Kodo
Fuzzy's code is perfect for this; it’s simple and easy to implement! You don’t need to add it to every actor either which save a lot of effort! Simply put the code you want to run while your game is paused, like the pause menu etc within the while loop!