Author Topic: How to make a pause game gui appear? SOLVED  (Read 798 times)

Gribbler

  • Posts: 1,489
  • I'm selling these fine leather jackets.
    • Gribbler worked on a game that won an AGS Award!
    •  
    • Gribbler worked on a game that was nominated for an AGS Award!
How to make a pause game gui appear? SOLVED
« on: 06 Apr 2013, 23:54 »
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: Adventure Game Studio
  1. function repeatedly_execute_always() {
  2.  
  3.   if (IsKeyPressed(eKeySpace) && !IsGamePaused())
  4.     {
  5.       SetSkipSpeech(2);
  6.       gPause.Visible = true;
  7.       spaceIsHeldToPause=true;
  8.     }
  9.     else if (spaceIsHeldToPause && !IsKeyPressed(eKeySpace)) spaceIsHeldToPause=false;
  10.     else if (!spaceIsHeldToPause && IsKeyPressed(eKeySpace) && IsGamePaused()) spaceIsHeldToUnpause=true;
  11.     else if (spaceIsHeldToUnpause && !IsKeyPressed(eKeySpace) && IsGamePaused())
  12.     {
  13.       SetSkipSpeech(0);
  14.       gPause.Visible = false;
  15.       spaceIsHeldToUnpause=false;
  16.     }
  17.  

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?
« Last Edit: 07 Apr 2013, 17:53 by Gribbler »

MurrayL

  • Posts: 195
    • I can help with AGS tutoring
    • I can help with backgrounds
    • I can help with play testing
    • I can help with proof reading
    • I can help with scripting
    • I can help with story design
    • I can help with voice acting
    • I can help with web design
Re: How to make a pause game gui appear?
« Reply #1 on: 07 Apr 2013, 13:38 »
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

  • Posts: 1,489
  • I'm selling these fine leather jackets.
    • Gribbler worked on a game that won an AGS Award!
    •  
    • Gribbler worked on a game that was nominated for an AGS Award!
Re: How to make a pause game gui appear?
« Reply #2 on: 07 Apr 2013, 17:53 »
Worked beautifully! Thanks so much, Murray!