0

助けが必要です。ここにこのコードがあり、弾丸を発射しますが、キーを押すたびに弾丸がどんどん速くなります。これが私が取り組んでいる部分です...

stage.addEventListener(KeyboardEvent.KEY_DOWN, kDown);
stage.addEventListener(KeyboardEvent.KEY_UP, kUp);
stage.addEventListener(Event.ENTER_FRAME, moveChar);

//character functionality keys//
function kDown(event:KeyboardEvent):void
{
var mainSpeed:int = 5;
    if (event.keyCode == 88){
        gun_mc.gotoAndPlay(2);
        BlueBullet_mc.x = gun_mc.x;
        BlueBullet_mc.y = gun_mc.y;
        addChild(BlueBullet_mc);
        BlueBullet_mc.addEventListener(Event.ENTER_FRAME,moveBlueBullet);
        }
        function moveBlueBullet(e:Event):void{
            e.target.y -=5;
            if (e.target == 0){
                e.target.removeEventListener(Event.ENTER_FRAME,moveBlueBullet);
                removeChild(MovieClip(e.target));

            }

        }
4

1 に答える 1