在ActionScript 3中暂停我的游戏问题

时间:2014-01-06 16:26:54

标签: events actionscript pausing-execution

在我的游戏中,我正在尝试添加暂停功能,按P键。它的工作原理但问题是,如果鼠标静止不动而我按下P键,没有任何反应,但是当我移动鼠标时它快速起作用。恢复没有问题。我怎样才能解决这个问题,让它在不移动鼠标的情况下工作? 这是代码

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;
     }
}

0 个答案:

没有答案