我正在尝试创建一个简单的消失的动作,当一个轮子击中一个特殊的消失的圆形剧本时。通常,轮子突破了一堆其他圆形颗粒,但是当随着轮子的与这个圆形颗粒碰撞时,动作暂停,动画剧,当动作恢复时,许多周围的圆粒子已经解散了。

问题是,车间需要从完整的停止中掉下来,但它继续刚刚刚刚反弹,现在不存在的圆形部分。 我难以清除力量。我已经尝试了init(),addforce()和更改.velocity amoung其他东西,但它一直希望继续横向弹跳运动。

我正在使用最新的Trunk版本猿,以捕获声音的碰撞事件。

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();
      }
}
}
.

有帮助吗?

解决方案

I think have a solution. I just re-instantiated the 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);   
 });

The only problem now is that the rotation of the wheel changes when you re-instantiate it.

Is there a way to manually change the rotation?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top