大量のコードでゲームを開発しています。ゲームの未完成バージョンはこちらにあります: http://rainisfalling.co.za/sheep-jump-test/
キー リスナーは 2 つあります。1 つは大きなジャンプのために SPACEBAR をリッスンし、もう 1 つは小さなジャンプのために CTRL をリッスンします。私が経験している問題は、2 つのボタンを正確に同時に押すと、両方のジャンプ アクションが発生し、非常に大きなジャンプが発生することです。(2 つのジャンプの高さの組み合わせ。)
これが私のコードの簡略版です:
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
}