缓动公式

公式总结

简单缓动,长形:
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;

你可能感兴趣的:(java,spring)