# 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;

• 本文已收录于以下专栏：

举报原因： 您举报文章：making things move as3 ---缓动和弹性公式 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)