0

当 WheelParticle 击中一个特殊的消失 CircleParticle 时,我正在尝试创建一个简单的消失动作。通常 WheelPartical 会从一堆其他 CircleParticle 上反弹,但是当 WheelParitcal 与此 CircleParticle 碰撞时,动作暂停,动画播放,当动作恢复时,许多周围的圆形粒子消失了。

问题是 WheelParticle 需要从一个完全停止处下降,但它会继续,就好像刚刚从现在不存在的 CircleParticle 反弹一样。我在清理部队时遇到了麻烦。我已经尝试过 init()、addForce() 和改变 .velocity 以及其他东西,但它一直想要继续横向弹跳运动。

我正在使用 APE 的最新中继版本来捕获声音的碰撞事件。

package{

import flash.display.MovieClip;
import flash.events.*;  
    import org.cove.ape.*;

public class DropTest extends MovieClip {

    public var self;
    public function DropTest(){
        self = this;

        APEngine.init(0.25);
        APEngine.container = this;
        //APEngine.damping = 0.92;
        APEngine.addForce(new VectorForce(false,0,15));

         var defaultGroup = new Group();
         defaultGroup.collideInternal = true;

         var peg1 = new CircleParticle(10, 30, 5, true, 0.2, 0.3);
         defaultGroup.addParticle(peg1);

          var peg2 = new CircleParticle(35, 30, 5, true, 0.2, 0.3);
         defaultGroup.addParticle(peg2);


         APEngine.addGroup(defaultGroup);           

         peg2.addEventListener(CollisionEvent.COLLIDE, function(evt:CollisionEvent){
                self.removeEventListener(Event.ENTER_FRAME, runAPE);    

                defaultGroup.removeParticle(peg2);
/*  The Wheel needs to stop and drop straight down from here.
                This doesn't seem to work.*/
                wheel.init();

                self.addEventListener(Event.ENTER_FRAME, runAPE);   
         });

        var wheel = new WheelParticle(12, 0, 10, false, 3);
        defaultGroup.addParticle(wheel);

        this.addEventListener(Event.ENTER_FRAME, runAPE);   

    }

    private function runAPE(evt:Event):void {
         APEngine.step();
         APEngine.paint();
      }
}
}
4

1 回答 1

0

我想有一个解决办法。我刚刚重新实例化了 WheelParticle

peg2.addEventListener(CollisionEvent.COLLIDE, function(evt:CollisionEvent){
            self.removeEventListener(Event.ENTER_FRAME, runAPE);    

            defaultGroup.removeParticle(peg2);
/*  The Wheel needs to stop and drop straight down from here.
            This doesn't seem to work.*/

           //  Replace with this
            defaultGroup.removeParticle(wheel);
            wheel = new WheelParticle(wheel.px,  wheel.px, 10, false, 3);
            defaultGroup.addParticle(wheel);


            self.addEventListener(Event.ENTER_FRAME, runAPE);   
 });

现在唯一的问题是,当您重新实例化它时,轮子的旋转会发生变化。

有没有办法手动改变旋转?

于 2011-05-17T17:55:52.770 回答