2017-11-28 5 views
0

나는 이것이 오래된 기술이라는 것을 알고있다. 그러나 나는 단지 플래시 카드로 업데이트를 보내고 싶다. 기본적으로 필자는 마우스를 따라가며 금 입자를 분출하는 입자 스크립트 (아래에서 찾아 볼 수 있습니다)를 사용합니다. 이 객체를 화면에 가로 지르는 트위닝 된 객체 뒤에서 따르도록하려면이 객체를 반대해야합니다. 나는 이벤트 리스너를 무언가로 바꾸는 경우일지도 모른다고 생각했지만 그것을 이해할 수 없었다.액션 스크립트 2 입자

편집 - 내 목적은 어떤 도움을 주시면 감사

썰매라는 무비 클립입니다.

스크립트 (AS2)

//import bitmap class 
import flash.display.BitmapData; 

//Settings 
var particleMaxSpeed:Number = 3; 
var particleFadeSpeed:Number = 5; 
var particleTotal:Number = 5; 
var particleRange:Number = 25; 

/** 
* createExplosion(target X position, target Y position) 
*/ 
function createExplosion(targetX:Number, targetY:Number):Void 
{ 
    //run for loop based on particleTotal 
    for (var i:Number = 0; i<particleTotal; i++) { 
     //attach bitmap from the library with the linked name "adobe_flash" 
     var myBmp:BitmapData = BitmapData.loadBitmap("fire.jpg"); 

     //create the "main_holder" movieclip that will hold our bitmap 
     var particle_mc = _root.createEmptyMovieClip("main_holder", _root.getNextHighestDepth()); 

     //create an "internal_holder" movieclip inside "main_holder" that we'll use to center the bitmap data 
     var internal_holder:MovieClip = particle_mc.createEmptyMovieClip("internal_holder", particle_mc.getNextHighestDepth()); 

     //set "internal_holder" x and y position based on bitmap size 
     internal_holder._x = -myBmp.width/2; 
     internal_holder._y = -myBmp.height/2; 

     //finally, attach the bitmapData "myBmp" to the movieclip "internal_holder" 
     internal_holder.attachBitmap(myBmp, internal_holder.getNextHighestDepth(), "never", true); 

     //set position & rotation, alpha 
     particle_mc._x = targetX 
     particle_mc._y = targetY 
     particle_mc._rotation = random(360); 
     particle_mc._alpha = random(50)+50; 

     //set particle boundry    
     particle_mc.boundyLeft = targetX - particleRange; 
     particle_mc.boundyTop = targetY - particleRange; 
     particle_mc.boundyRight = targetX + particleRange; 
     particle_mc.boundyBottom = targetY + particleRange; 

     //set speed/direction of fragment 
     particle_mc.speedX = Math.random(particleMaxSpeed)-Math.random(particleMaxSpeed); 
     particle_mc.speedY = Math.random(particleMaxSpeed)-Math.random(particleMaxSpeed); 
     particle_mc.speedX *= particleMaxSpeed 
     particle_mc.speedY *= particleMaxSpeed 

     //set fade out speed 
     particle_mc.fadeSpeed = Math.random(particleFadeSpeed)*particleFadeSpeed; 

     //just a visual particle counter 
     numberOfParticles++; 

     //make fragment move using onEnterFrame 
     particle_mc.onEnterFrame = function():Void 
     { 
      //update alpha, x, y 
      this._alpha -= this.fadeSpeed; 
      this._x += this.speedX; 
      this._y += this.speedY; 
      //if fragment is invisible or out of bounds, remove it 
      if (this._alpha <= 0 || this._x < this.boundyLeft || this._x > this.boundyRight || this._y < this.boundyTop || this._y > this.boundyBottom) 
      { 
       this.removeMovieClip(); 
       // 
       numberOfParticles--; 
      } 
     } 
    } 
} 

/** 
* Mouse Controls 
*/ 
//create an object that we'll listen to 
mouseListener = new Object(); 

//on Click, createExplosion 
mouseListener.onMouseDown = function() { 
    //createExplosion(_xmouse, _ymouse); 
} 
mouseListener.onMouseMove = function() { 
    createExplosion(_xmouse, _ymouse); 
} 

//add listener 
Mouse.addListener(mouseListener); 

답변

0

당신은 createExplosion 기능마다 프레임을 호출하고 께 sleigh X를 통과해야하고, Y 대신 마우스 좌표를 조정한다.

sleigh.onEnterFrame = function() { 
    createExplosion(sleigh._x, sleigh._y); 
} 

mouseListener.onMouseMove = function() { 
    createExplosion(_xmouse, _ymouse); 
} 

교체하고 다른 마우스 리스너 물건을 제거