落瓶不落

falling bottle not falling

我想制作一个落物游戏。在这种情况下,我只有一个瓶子,我想让它掉下来,但它不起作用。正如你在图片中看到的,瓶子开始变形,但它并没有掉下来。谢谢!

   function bottleCreate(e:Event):void {

    var bottleNew:MovieClip;

    bottleNew = newBottle();
        bottleNew.x = 100;
        bottleNew.y=0;

    addChild(bottleNew);
bottle.addEventListener(Event.ENTER_FRAME, bottleMove);
}

function bottleMove(e:Event):void {
        e.target.y ++;          
}

stage.addEventListener(Event.ENTER_FRAME, bottleCreate);

您应该删除 bottleCreate 函数的事件侦听器,通过 添加

stage.removeEventListener(Event.ENTER_FRAME, bottleCreate);

到你的 bottleCreate 函数。

调用 bottleCreate 函数一次,而不是使用

stage.addEventListener(Event.ENTER_FRAME, bottleCreate);

不会变形。您在每帧添加新瓶子 (100,0) 所以它看起来像是扭曲但实际上每 1 像素有一个新实例

只调用 bottleCreate() 一次