Page 1 of 1

pausing the game while displaying a main menu

PostPosted: Sat Jun 21, 2008 9:11 pm
by biffo
[img]OK, I get how to make a pause menu using PauseGameOn()/Off(),
but my issue is how do I make a menu that has some elements that are still dynamic, (IE recieveing events, and updating screen position like a menu cursor,) while the gameplay elements are all frozen?
PauseGameON() seems to only be good for pausing every actor in the game. Am I incorrect?
are actors created after PauseGameON() is called still updatable?
is their a way to exclude a few 'special' actors from the PauseGameOn() function?

conversely, is there some way to pause the timer on an actor completely?
EventDIsable is a good start but my physics continue to operate on a DrawActor basis
TIA

Re: pausing the game while displaying a main menu

PostPosted: Sun Jun 22, 2008 7:59 pm
by Bee-Ant
This is quite dificult.you need to stop all moving object except your menu by EventDisable,make their directional_velocity to 0,or using variable while you pause the game.

Re: pausing the game while displaying a main menu

PostPosted: Sun Jun 22, 2008 10:19 pm
by Fuzzy
Make a global var called PauseActors of type integer. in your menu have a pause button that flips the value of that variable between zero and one.

in the beginning of the draw event for each actor put
Code: Select all

if (PauseActors ==1)
{
    EventDisable("Event Actor", EVENTALL);
}
else
{
    EventEnable("Event Actor", EVENTALL);
}

Re: pausing the game while displaying a main menu

PostPosted: Mon Jun 23, 2008 5:55 am
by Bee-Ant
But Fuzzy,can you make able all events after you disabled all events by that actor itself.i dont think so...

Re: pausing the game while displaying a main menu

PostPosted: Mon Jun 23, 2008 6:33 am
by DST
Bee ant has a point. Won't that disable the draw actor too?

Re: pausing the game while displaying a main menu

PostPosted: Mon Jun 23, 2008 6:45 pm
by Bee-Ant
Theres no way except disable the specific events,directional velocity,and animation direction.

Re: pausing the game while displaying a main menu

PostPosted: Tue Jun 24, 2008 7:40 am
by biffo
This sounds like it should work. I'll try it tomorrow night.
Thanks fellas! wish me luck.

Re: pausing the game while displaying a main menu

PostPosted: Wed Jun 25, 2008 5:54 am
by biffo
So it looks like Bee ant is right.
Allthough calling event disable on the draw actor doesnt' seem to stop the actor from drawing FYI
conversely even before I tried this I thought of attaching the eventdisable call to the menu thinking the menu at that point could contain the calls to disable the active sprites.
Alas this didn't as Bee pointed out stop the velocity and drawing from updating.
Niether did calling the event disable on the timer which kind of suprised me. I suppose at this point the bulletproof solution would be to pass all the velocity to holder variables and zero them out.
I thought according to what I read though that creating sprites after the PauseGameOn would still work. Shouldn't they? It doesnt seem to....
Still looking for an elegant solution.
thanks for everyones feedback.
possibly write one function in global script that handles storing all the dynamic elements velocitys and then zeroing them out,
then a second one to reload the velocitys?

Re: pausing the game while displaying a main menu

PostPosted: Wed Jun 25, 2008 8:04 am
by Bee-Ant
Well,thats the hard point "restoring the value". I use this to pause my player
Code: Select all
directional_velocity=0;
EventDisable("Event Actor", EVENTANIMATION);
EventDisable("Event Actor", EVENTCOLLISION);
EventDisable("Event Actor", EVENTKEYDOWN);
EventDisable("Event Actor", EVENTKEYUP);
EventDisable("Event Actor", EVENTTIMER);
ChangeAnimationDirection("Event Actor", STOPPED);

Use this code for AnyActor>Keydown>PauseKey>ScriptEditor
To unpause them...

Re: pausing the game while displaying a main menu

PostPosted: Wed Jun 25, 2008 2:20 pm
by DST
Feral, I think it's time for you to make us another demo...... :lol:

Re: pausing the game while displaying a main menu

PostPosted: Wed Jun 25, 2008 2:33 pm
by Bee-Ant
Why you asked for feral DST?you said you like making game...even 10 mins after wake up...lol
Oops,is that a secret?

Re: pausing the game while displaying a main menu

PostPosted: Wed Jun 25, 2008 10:18 pm
by feral
DST wrote:Feral, I think it's time for you to make us another demo...... :lol:



um yeah... thanks mate...'cough'...

actually...well I did have a quick go at a solution, but, it has to sacrifice a complete game "frame" to un-pause, so would be useful for somethings, others like fast action, may get a bit difficult. but it does stop all action ( except timers so these can't be used with this method .......... mmmm.. just thought ...unless you reset them after pause :? will look at that ( tho i hate timers )

anyhow, everything pauses, using one function, and no need to do things to all actors like event disables or stuff, and then the advantage is you can still do menus, jump to help screens etc...but at the cost of a frame of game action..

in other words you need to access the view's "draw feature" ( so game goes ahead one frame) and if you mess around in the menus - then every click or menu action needs another draw frame ... i didn't like the method much so gave up until i could think of something better,... but it works sort of

would that be worth a demo of ?

basically it goes

on key down "p"
pause=1

then in view draw

while (pause==1)
{
// menu code until pause=0
}


feral

Re: pausing the game while displaying a main menu

PostPosted: Wed Jun 25, 2008 11:21 pm
by makslane
This while will freeze the game.

Re: pausing the game while displaying a main menu

PostPosted: Thu Jun 26, 2008 1:50 am
by feral
makslane wrote:This while will freeze the game.


oops i may have said it wrong..

demo shortly

feral

Re: pausing the game while displaying a main menu

PostPosted: Thu Jun 26, 2008 2:11 am
by feral
ok..

sorry, I misspoke ..

the while loop is in a function in global, however it can switch back and forth to the view draw using "flags"

if pauseon=1 do global loop

depending on which key pressed reassign pauseon with new flag, do one screen refresh ( using view) then if required return to while loop ( ie: the menu options)

if unpaused selected escape loop by setting pauseon flag to 0

left-control key to pause
while in menu
h for help
r to return to menu
u to unpause

main pieces of code are
left-control key down - sets pauseon to flag 5
some code at the start of draw view
and the rest is a function in gloabl..

it is all very rough, as i said i wasn't completely happy with it....

sorry for the biggish download, but i was testing it on a game of mine

feral

PS: is also unfinished because each draw refresh CAN write to the current view ( which may be the help screen at the time... becuase currently the view changes to anothe area to display help..

I just didn't get that far to look into it.. BUT the easy solution would be to have a menu and help screen that covered up the current game view, so any redraws happened in the right place but not be seen..