Hello guys, how to pause with the letter P with add listener or something, except this example:
Code:if (Key.isDown(letter))
{
pause = true;
}
Printable View
Hello guys, how to pause with the letter P with add listener or something, except this example:
Code:if (Key.isDown(letter))
{
pause = true;
}
Thank you guys :P, but, case the pause is true, and the player press letter P to unpause the game, this is valid?
PHP Code:var listener:Object = new Object();
listener.onKeyDown = function() {
if (Key.getCode() == 80) {
if (!pause)
{
pause = true;
}
else
{
pause = false;
}
}
};
Key.addListener(listener);
Hi,
Try something along the lines of
PHP Code:var isPaused:Boolean = false;
function doPause(arg:Boolean):Void
{
if (arg)
{
trace("Paused");
}
else
{
trace("unPaused");
}
}
var pListener:Object = new Object();
pListener.onKeyDown = function():Void
{
if (Key.getCode() == 80)
{
isPaused = !isPaused;
doPause(isPaused);
}
};
Key.addListener(pListener);
This seems to suit me, thanks man.
:smoov: