Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gribbler on Sat 06/04/2013 23:54:48

Title: How to make a pause game gui appear? SOLVED
Post by: Gribbler on Sat 06/04/2013 23:54:48
Hi!

I'm struggling with a pause feature for the game. I consulted Ryan Timothy on the forums and he came out with this script:

Code (AGS) Select

function repeatedly_execute_always() {
 
  if (IsKeyPressed(eKeySpace) && !IsGamePaused())
    {
      SetSkipSpeech(2);
      gPause.Visible = true;
      spaceIsHeldToPause=true;
    }
    else if (spaceIsHeldToPause && !IsKeyPressed(eKeySpace)) spaceIsHeldToPause=false;
    else if (!spaceIsHeldToPause && IsKeyPressed(eKeySpace) && IsGamePaused()) spaceIsHeldToUnpause=true;
    else if (spaceIsHeldToUnpause && !IsKeyPressed(eKeySpace) && IsGamePaused())
    {
      SetSkipSpeech(0);
      gPause.Visible = false;
      spaceIsHeldToUnpause=false;
    }


I changed SetSkipSpeech to "mouse only" and added new "game paused" gui label, the game pauses like a charm but the gui is displayed only if there's no speech currently on the screen. In other words, when I pause the game during dialogue game pauses but without the gui, the gui is only visible if I pause the game while walking for example, or during animation. Do you know what to do to override speech and force gui to be displayed?

There was no repeatedly_execute_always function in my Global Script so I simply added "always" at the end of "repeatedly_execute"... I also created two global bool type variables as Ryan instructed (with no initial value).
Can this be caused by the GUI type? Button, label, texbox? I'm just clueless... Maybe some option in General Settings prevents the gui from being displayed?
Title: Re: How to make a pause game gui appear?
Post by: MurrayL on Sun 07/04/2013 13:38:45
I think it's probably because you have GUIs set to hide when the game is blocked.

Go to gPause and set the display mode to 'Always display'. This way the GUI will never be hidden by blocking routines, but we have to tell AGS to not display it until we want to, so in game_start (globalscript.asc), add gPause.Visible=false;.
Title: Re: How to make a pause game gui appear?
Post by: Gribbler on Sun 07/04/2013 17:53:29
Worked beautifully! Thanks so much, Murray!