Component to animate the change in 2D properties over time.
public this .tween(Object properties, Number duration)
This method will animate a 2D entities properties over the specified duration.
These include x
, y
, w
, h
, alpha
and rotation
.
The object passed should have the properties as keys and the value should be the resulting values of the properties.
Move an object to 100,100 and fade out in 200 frames.
Crafty.e("2D, Tween")
.attr({alpha: 1.0, x: 0, y: 0})
.tween({alpha: 0.0, x: 100, y: 100}, 200)