캠핑과 개발

// 무비클립을 탄력적으로 움직이게 하는 메서드

// a는 -2부터 2사이의 실수 (-2<a<2)

// b는 -1부터 0사이의 실수(-1<b<0)

// a*a+4b는 -4부터 0사이의 실수(-4<a*a+4b<0)

// b가 -1에 가까울수록 진동폭이 큼

// a가 -2에 가까울수록(작을수록) 속도가 빠름

// tx와 ty는 이동할 최종 위치


MovieClip.prototype.elasticMove = function(a, b, tx, ty){

     var tempx = this._x;

     var tempy = this._y;

     this._x = a*(this._x - tx) + b*(this.prevx - tx) + tx;

     this._y = a*(this._y - ty) + b*(this.prevy - ty) + ty;

     this.prevx = tempx;

     this.prevy = tempy;

};


[출처] http://blog.naver.com/sync6324/110033835026

// 부드러운 움직임

MovieClip.prototype.smoothMove = function(speed, targetx, targety){

    this._x += speed*(targetx - this._x);

    this._y += speed*(targety - this._y);

};



_root.무비클립인스턴스.smoothMove(0.2, _xmouse, _ymouse);


[출처] http://blog.naver.com/sync6324/110033835026

'DEVELOPMENT > IOS' 카테고리의 다른 글

아이폰 OS 개발 자료 총정리  (0) 2012.05.17
iPhone용 Open Source 모음  (0) 2012.05.17