我正在开发一个包含大量代码的游戏。游戏的未完成版本可以在这里找到:http ://rainisfalling.co.za/sheep-jump-test/
有两个关键监听器。一个听空格键表示大跳跃,另一个听 CTRL 表示小跳跃。我遇到的问题是,当两个按钮同时按下时,两个跳跃动作都会发生,导致超大跳跃。(两个跳跃高度的组合。)
这是我的代码的简化版本:
addEventListener(KeyboardEvent.KEY_DOWN, bigJump);
function bigJump(e:KeyboardEvent){
//check to see that keycode = SPACEBAR
//code to do the actual jump
//also remove the event listeners for the jumps while in the air
}
addEventListener(KeyboardEvent.KEY_DOWN, smallJump);
function smallJump(e:KeyboardEvent){
//check to see that keycode = CTRL
//code to do the actual jump
//also remove the event listeners for the jumps while in the air
}