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?
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;
}
}
}
Or shorter:
if (keycode == eKeyP) pausescreen.Visible = !pausescreen.Visible;
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.
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?
Never mind, done it now
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;