휠을 중지하고 재설정하십시오 - APE (ActionScript Physics Engine) (최신 트렁크)

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

문제

WheelParticle이 특별한 사라지는 일방병을 때리면 간단한 사라지는 행동을 만들려고합니다.일반적으로 휠링은 다른 모든 서클 마리클리클의 무리에서 튀어 나오지 만,이 일방병과 함께 충돌 할 때, 조치가 일시 중지되면, 애니메이션이 재생되고, 동작이 재개 될 때, 많은 주변의 원형 입자가 분리되었다.

문제는 WheelParticle이 완전한 정류장에서 방지해야하지만 이제는 존재하지 않는 일방병으로 방금 튀는 것처럼 계속됩니다. 나는 힘을 제거하는 데 어려움이 있습니다.나는 init (), addForce ()를 시도하고 다른 것들을 바꾸고 다른 것들을 바꾸고 있지만, 그것은 측면 튀는 움직임을 계속하고 싶습니다.

사운드의 충돌 이벤트를 캡처하기 위해 최신 트렁크 버전을 사용하고 있습니다.

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