M1KE
02-19-2009, 10:57 PM
Hi! I have a game hear that I need to unpause and pause it with the letter p (key 80). The pausing works and the unpausing works but you have to be quick. For instance if you hold down p for a long period of time it flash between the paused state and the unpaused state. Is there a way how I can set a time here is what i have:
function Pause() {
if (Key.isDown(80)) {
if (Paused) {
setInterval(Pause,3000)
Paused = false;
} else {
Paused = true;
setInterval(Pause,3000)
}
}
if (Paused) {
_root.Pac.Move = false;
_root.Pac.gotoAndStop(1);
_root.Monster1.Move = false;
_root.Monster2.Move = false;
_root.Monster3.Move = false;
_root.Monster4.Move = false;
_root.Monster5.Move = false;
_root.Pac._alpha = 15;
_root.PauseText._alpha = 100;
_root.Monster1._alpha = 15;
_root.Monster2._alpha = 15;
_root.Monster3._alpha = 15;
_root.Monster4._alpha = 15;
_root.Monster5._alpha = 15;
_root.Food._alpha = 15;
} else if (Paused == false) {
_root.Pac.play();
_root.Pac.Move = true;
_root.Monster1.Move = true;
_root.Monster2.Move = true;
_root.Monster3.Move = true;
_root.Monster4.Move = true;
_root.Monster5.Move = true;
_root.Pac._alpha = 100;
_root.PauseText._alpha = 0;
_root.Monster1._alpha = 100;
_root.Monster2._alpha = 100;
_root.Monster3._alpha = 100;
_root.Monster4._alpha = 100;
_root.Monster5._alpha = 100;
_root.Food._alpha = 100;
}
}
I'm trying to make it pausing when you press 'p' but you can't unpause it till 3 seconds later to stop the flash thing. the function 'Pause is then put in the actions for Pac. 9If you've guesseed this is a Pac man sort of game.
Thanks in advance!
function Pause() {
if (Key.isDown(80)) {
if (Paused) {
setInterval(Pause,3000)
Paused = false;
} else {
Paused = true;
setInterval(Pause,3000)
}
}
if (Paused) {
_root.Pac.Move = false;
_root.Pac.gotoAndStop(1);
_root.Monster1.Move = false;
_root.Monster2.Move = false;
_root.Monster3.Move = false;
_root.Monster4.Move = false;
_root.Monster5.Move = false;
_root.Pac._alpha = 15;
_root.PauseText._alpha = 100;
_root.Monster1._alpha = 15;
_root.Monster2._alpha = 15;
_root.Monster3._alpha = 15;
_root.Monster4._alpha = 15;
_root.Monster5._alpha = 15;
_root.Food._alpha = 15;
} else if (Paused == false) {
_root.Pac.play();
_root.Pac.Move = true;
_root.Monster1.Move = true;
_root.Monster2.Move = true;
_root.Monster3.Move = true;
_root.Monster4.Move = true;
_root.Monster5.Move = true;
_root.Pac._alpha = 100;
_root.PauseText._alpha = 0;
_root.Monster1._alpha = 100;
_root.Monster2._alpha = 100;
_root.Monster3._alpha = 100;
_root.Monster4._alpha = 100;
_root.Monster5._alpha = 100;
_root.Food._alpha = 100;
}
}
I'm trying to make it pausing when you press 'p' but you can't unpause it till 3 seconds later to stop the flash thing. the function 'Pause is then put in the actions for Pac. 9If you've guesseed this is a Pac man sort of game.
Thanks in advance!