Re: [问题] 游戏中 子弹发射的间隔

楼主: puivujh (眼残)   2013-10-10 20:06:28
吃光
private var keys:Array = [];
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
private function onKeyDown(event:KeyboardEvent):void
{
keys[event.keyCode] = true;
}
private function onKeyUp(event:KeyboardEvent):void
{
keys[event.keyCode] = false;
}
private function onEnterFrame(event:Event):void
{
if (keys[Keyboard.LEFT]) player.x -= SPEED;
if (keys[Keyboard.RIGHT]) player.x += SPEED;
}
试看看
专治按键打架

Links booklink

Contact Us: admin [ a t ] ucptt.com