Crafty.easing Class

An object for tracking transitions. Typically used indirectly through "SpriteAnimation", "Tween", or viewport animations.

If a method allows you to specify the type of easing, you can do so by providing a custom function or a string corresponding to the name of a built-in method.

Built-in easing functions are "linear", "smoothStep", "smootherStep", "easeInQuad", "easeOutQuad", and "easeInOutQuad".

A custom function will be passed a parameter t which will vary between 0 and 1, and should return the progress of the animation between 0 and 1.

Example

Here is how you might use easing functions with the "Tween" component.

var e = Crafty.e("2D, Tween");
// Use built-in easing functions
e.tween({x:100}, 1000, "smoothStep");
e.tween({y:100}, 1000, "easeInQuad");
// Define a custom easing function: 2t^2 - t
e.tween({w:0}, 1000, function(t){return 2*t*t - t;});