我正在开发一个具有大量代码的游戏。未完成的游戏版本可以在这里找到:http://rainisfalling.co.za/sheep-jump-test/AS3 - 避免同时按下两个按钮
有两个关键听众。一个听大空间的SPACEBAR,另一个听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
}
非常感谢!我真的应该想到这个......我的大脑被炸了。 – CptRayMar 2012-03-28 22:07:42