Pause Screen

Started by shaungaryevans, Thu 30/04/2009 12:20:09

Previous topic - Next topic

shaungaryevans

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?

Hudders

Make a gui for the pause screen and then add an if statement to the on_key_press function.

Something like:

Code: ags

function on_key_press(eKeyCode keycode)
{
  if (keycode == eKeyP)
  {
     if (pausescreen.Visible == true)
     {
        pausescreen.Visible = false;
     }
     else
     {
        pausescreen.Visible = true;
      }
  }
}

Khris

Or shorter:

Code: ags
  if (keycode == eKeyP) pausescreen.Visible = !pausescreen.Visible;

Matti


Code: ags
  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.

shaungaryevans

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?

shaungaryevans

Never mind, done it now

Khris

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;

SMF spam blocked by CleanTalk