# 叶落为重生每片落下的叶子都是为了下一次的涅槃...^_^

## 【备忘】bounce ease

Bounce: { easeIn: function(t,b,c,d){ return c - Tween.Bounce.easeOut(d-t, 0, c, d) + b; }, easeOut: function(t,b,c,d){ if ((t/=d) < (1/2.75)) { return c*(7.5625*t*t) + b; } else if (t < (2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
} else if (t < (2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
} else {
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
}
},
easeInOut: function(t,b,c,d){
if (t < d/2) return Tween.Bounce.easeIn(t*2, 0, c, d) * .5 + b;
else return Tween.Bounce.easeOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
}
}

move: function () {
var disX = this.endX - this.x;
var disY = this.endY - this.y;
var dis = Math.sqrt(Math.pow(disX, 2) + Math.pow(disY, 2));
var force = dis * parseFloat(document.getElementById('force').value);
var angle = Math.atan2(disY, disX); // atan2(x, y) 表示 点（x,y）到x轴的弧度

this.vx += force * Math.cos(angle);
this.vy += force * Math.sin(angle);

this.vx *= 0.92;
this.vy *= 0.92;

//
this.x += this.vx;
this.y += this.vy;
},

Demo 1

Demo 2

posted on 2011-12-22 21:58 岑安 阅读(...) 评论(...) 编辑 收藏

• 随笔 - 78
• 文章 - 0
• 评论 - 930