How to make a pause game gui appear? SOLVED

Started by Gribbler, Sat 06/04/2013 23:54:48

Previous topic - Next topic

Gribbler

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

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?

MurrayL

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;.

Gribbler

Worked beautifully! Thanks so much, Murray!

SMF spam blocked by CleanTalk