craftyjs/Crafty — pull request #583 by starwed (2013-10-26 02:08:12+00:00)
Title: Refactor animation.js to use a time based rather than frame based approach.

There are still some issues with this, but the base functionality is there! In particular
* How durations are handled should be discussed
* Exactly when "SpriteAnimation" should trigger events is unclear to me. When should "FrameChange" fire -- literally any time the frame changes, or only when it does so as a result of the animation?
* More comprehensive tests are needed, and, probably, some additional examples in the docs
* It just generally needs some more eyes on the new interface for SpriteAnimation! :)

*Commit notes below:*

Crafty.easing
---------------
- A new object `Crafty.easing`; it abstracts the concept of a state that changes over time.
- Used in the new "Tween" and "SpriteAnimation" components; can also be used when we fix the viewport animation functions.
- Currently treats durations as a number of frames when given as a number, or as a number of ms when given as a string. Time based is probably a better default, but would break backwards compatibility.
- No public documentation right now, since it's for internal use.
- Added tests in core.html

Tween
---------------
- Uses the new easing object
- Now treats a set of properties to tween as a group, only sending one "TweenEnd" event per group
- Removes some special handling for mouse events that I'm pretty sure is already handled by how the "2D" component works.
- Updated the docs and added tests in core.html

SpriteAnimation
---------------
- Uses the new easing object
- Refactored the interface completely. Uses `reel()` to set and change reels, `animate()` to play them. Favors composable single purpose methods over tons of optional arguments. See documentation/source for full details.
- The duration of an animation is now set when creating a reel, instead of when playing it.
- Updated the docs and tests in animation.html