アットウィキロゴ

ムービークリップを指定位置までモーション形式で移動させる

考え方

あるムービークリップの座標(x,y)をターゲットとなる座標(target_x,target_y)に問う減速運動で移動させる。

function movetargetFunc(target_x,target_y){
  this.onEnterFrame = this.moveRoutine;
}
 
function moveRoutine(){
  cons_speed  = 5;   //ターゲットに向かう速度定数
  cons_accep  = 3;   //終着の許容範囲(ピクセル)
 
  this._x += (target_x -this._x)/cons_speed; 
  this._y += (target_y -this._y)/cons_speed;
 
  if (Math.abs(target_x - this._x) <= cons_accep){
	delete this.onEnterFrame;
	this._x = target_x;
        this._y = target_y;
  }
 
 }
最終更新:2007年08月22日 04:12