Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: shaungaryevans on Thu 30/04/2009 12:20:09

Title: Pause Screen
Post by: shaungaryevans on Thu 30/04/2009 12:20:09
hi,

I want to have my pause menu come up when I press the letter 'P' on my keyboard. How would I do this please?
Title: Re: Pause Screen
Post by: Hudders on Thu 30/04/2009 12:29:45
Make a gui for the pause screen and then add an if statement to the on_key_press function.

Something like:


function on_key_press(eKeyCode keycode)
{
  if (keycode == eKeyP)
  {
     if (pausescreen.Visible == true)
     {
        pausescreen.Visible = false;
     }
     else
     {
        pausescreen.Visible = true;
      }
  }
}
Title: Re: Pause Screen
Post by: Khris on Thu 30/04/2009 13:19:08
Or shorter:

  if (keycode == eKeyP) pausescreen.Visible = !pausescreen.Visible;
Title: Re: Pause Screen
Post by: Matti on Thu 30/04/2009 13:40:16

  if (keycode == eKeyP) pausescreen.Visible = !pausescreen.Visible;

What, that would work? I've never seen a line of script like that but hell, it's short and practical.
Title: Re: Pause Screen
Post by: shaungaryevans on Thu 30/04/2009 14:15:30
i've have do this code:

if (keycode == eKeyP) pausescreen.Visible = !pausescreen.Visible;

how would I centre the gui now. What do i need to add in this code please?
Title: Re: Pause Screen
Post by: shaungaryevans on Thu 30/04/2009 14:16:57
Never mind, done it now
Title: Re: Pause Screen
Post by: Khris on Thu 30/04/2009 14:57:11
Quote from: Mr Matti on Thu 30/04/2009 13:40:16What, that would work? I've never seen a line of script like that but hell, it's short and practical.

Sure, true == !false and false == !true.
Similarly, if you want to toggle a variable between 0 and 1, you can call var = 1-var;