Question

In my game I'm trying to add a Pause function, pressing P key. It works but the problem is that if the mouse stands still and I press P key, nothing happens but while I move the mouse it fastly works. to resume there is no problem. How can I fix that, to let it work without moving the mouse? Here is the code

stage.addEventListener(KeyboardEvent.KEY_DOWN, pauseGame);
function pauseGame(e:KeyboardEvent):void{
     if(!gamePaused && (e.keyCode == 80)){
     rect_Darken.x = STAGE_CENTER.x;
     rect_Darken.y = STAGE_CENTER.y;
     txt_Pause.x = STAGE_CENTER.x;
     txt_Pause.y = STAGE_CENTER.y;
     gamePaused = true;
     stage.frameRate = 0;
     }else if(e.keyCode == 80){
     stage.frameRate = 24;
     rect_Darken.x = 270;
     rect_Darken.y = 670;
     txt_Pause.x = 270;
     txt_Pause.y = 670;
     gamePaused = false;
     }
}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top