Pausing the game

Non-platform specific questions.

Pausing the game

Postby arcreamer » Thu Jul 26, 2007 3:29 pm

can someone show me how to pause the game by pressing P for pause to create a pause actor and pressing P to unpause?
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby Sgt. Sparky » Thu Jul 26, 2007 4:30 pm

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. :( )
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby arcreamer » Thu Jul 26, 2007 6:23 pm

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 =(
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby pixelpoop » Thu Jul 26, 2007 11:08 pm

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;
}
Last edited by pixelpoop on Thu Jul 26, 2007 11:43 pm, edited 1 time in total.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby arcreamer » Thu Jul 26, 2007 11:16 pm

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?
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby arcreamer » Thu Jul 26, 2007 11:17 pm

nvm i added a variable called gamePaused and got it all working thanks!
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby pixelpoop » Thu Jul 26, 2007 11:43 pm

I update my first post with:
create a variable called gamePaused
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby arcreamer » Fri Jul 27, 2007 2:06 am

I got it; thanks! :)
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby Fuzzy » Fri Jul 27, 2007 2:45 am

in views draw event..

Code: Select all
while(Pause == 1)
{
    if (getLastKey() == KEY_p)
    {
    Pause = !Pause;
    }
}
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby makslane » Fri Jul 27, 2007 12:57 pm

This while will lock your game.
Just check the key, or, better, put the check in a Key Down event.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby DilloDude » Fri Jul 27, 2007 11:50 pm

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby arcreamer » Sat Jul 28, 2007 12:49 am

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?
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby pixelpoop » Sat Jul 28, 2007 7:19 am

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.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby pixelpoop » Sat Jul 28, 2007 7:25 am

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.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby Kodo » Sat Jul 28, 2007 9:57 am

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!
Inogames: http://www.inogames.com iOS gaming
Firetop Adventure (app store): http://itunes.apple.com/us/app/firetop- ... ?mt=8&ls=1
User avatar
Kodo
 
Posts: 449
Joined: Thu Oct 20, 2005 8:20 pm
Location: UK
Score: 23 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron