making things move as3 ---缓动和弹性公式

简单缓动,长形:

var dx:Number = targetX - sprite.x;

var dy:Number = targetY - sprite.y;

vx = dx * easing;

vy = dy * easing;

sprite.x += vx;

sprite.y += vy;


简单缓动,中形:

vx = (targetX - sprite.x) * easing;

vy = (targetY - sprite.y) * easing;

sprite.x += vx;

sprite.y += vy;


简单缓动,短形:

sprite.x += (targetX - sprite.x) * easing;

sprite.y += (targetY - sprite.y) * easing;

简单弹性,长形:

var ax:Number = (targetX - sprite.x) * spring;

var ay:Number = (targetY - sprite.y) * spring;

vx += ax;

vy += ay;

vx *= friction;

vy *= friction;

sprite.x += vx;

sprite.y += vy;


简单弹性,中形:

vx += (targetX - sprite.x) * spring;

vy += (targetY - sprite.y) * spring;

vx *= friction;

vy *= friction;

sprite.x += vx;

sprite.y += vy;

简单弹性,短形:

vx += (targetX - sprite.x) * spring;

vy += (targetY - sprite.y) * spring;

sprite.x += (vx *= friction);

sprite.y += (vy *= friction);


偏移弹性运动:

var dx:Number = sprite.x - fixedX;

var dy:Number = sprite.y - fixedY;

var angle:Number = Math.atan2(dy, dx);

var targetX:Number = fixedX + Math.cos(angle) * springLength;

var targetY:Number = fixedX + Math.sin(angle) * springLength;

阅读更多
文章标签: spring
想对作者说点什么? 我来说一句

AS3中常用到的公式

2010年03月15日 79KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭