停止とリセットホイールの部品 - ActionScript Physics Engine(APE)(最新のトランク)

StackOverflow https://stackoverflow.com/questions/6023903

質問

車輪粒子が特別な円形の同級区を打つときに簡単な消えた行動を作りようとしています。通常、他のCircleParticlesの束からなる車輪が跳ね返っているが、車輪パラチカルがこの同区と衝突したとき、行動一時停止、アニメーションが再生され、そして行動が再開されたとき、多くの周囲の円粒子が不良をした。

問題は、完全な停留所から落下するだけでよいが、存在しない同区から跳ね返っているだけであれば続けている。 力を消すのに問題があります。私はinit()、addforce()を試してみました。

サウンドの衝突イベントをキャプチャするために、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();
      }
}
}
.

役に立ちましたか?

解決

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