탄성을 갖고 움직이게 하는 플래시 함수
// 무비클립을 탄력적으로 움직이게 하는 메서드
// 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;
};
'DEVELOPMENT > FLEX & AIR' 카테고리의 다른 글
flash player 설치 관련 (0) | 2013.01.22 |
---|---|
actionscript 유용한 라이브러리 (0) | 2012.05.31 |
두 지점사이의 거리를 구하는 메서드 공식 (0) | 2012.05.30 |
특정 지점을 바라보게 하기위한 각도를 구하는 메서드 공식 (0) | 2012.05.30 |
BorderContainer image background 활용 (0) | 2011.08.24 |
특정지점으로 부드럽게 움직이는 메서드 공식
// 부드러운 움직임
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);
'DEVELOPMENT > IOS' 카테고리의 다른 글
아이폰 OS 개발 자료 총정리 (0) | 2012.05.17 |
---|---|
iPhone용 Open Source 모음 (0) | 2012.05.17 |