Hello!
A few months ago, I was desperately in need for an animation library, in order to make nice splash screens and UI animations for my android game. However, while Flash is crawling under powerful tweening engines, there was no such thing for java. Therefore, I made one, open-source, which reached its maturity a few days ago with the release of its 6th major revision.
A tween is basically an interpolation between two values that runs for a given amount of time. Of course, the Tween Engine does a lot more than that, and handles the life-cycles and the update mechanisms of the interpolations for you. Moreover, it enables the interpolation of every attributes from any object in any Java project (being Swing, SWT, OpenGL, Android or even console-based).
// In one line, send your object to another position (here x=20 and y=30),
// with a smooth elastic transition, during 1 second (1000ms):
Tween.to(myObject, POSITION, 1000).target(20, 30).ease(Elastic.OUT).start(myManager);
// Also, create complex sequences:
Timeline.createSequence()
.push(Tween.set(...)) // First, set all objects to their initial positions
.push(Tween.set(...))
.push(Tween.set(...))
.pushPause(1000) // Wait 1 second
.push(Tween.to(...)) // Move the objects around, one after the other
.push(Tween.to(...))
.push(Tween.to(...))
.beginParallel() // Move them all at the same time now
.push(Tween.to(...))
.push(Tween.to(...))
.push(Tween.to(...))
.end()
.repeatYoyo(2, 500) // repeat the whole sequence 2 times
.start(myManager); // and finally start it!
Feature set:
- Zero allocation! Use your project safely on Android without fearing the garbage collector!
- Supports every interpolation function defined by Robert Penner: http://www.robertpenner.com/easing/
- Can be used with any object. You just have to implement the TweenAccessor interface when you want interpolation capacities.
- Every attributes can be interpolated. The only requirement is that what you want to interpolate can be represented as a float number.
- One line is sufficient to create and start a simple interpolation.
- Tweens can be easily sequenced thanks to Timelines.
- Tweens can act on more than one value at a time, so a single tween can change the whole position (X and Y) of a sprite for instance !
- Tweens and Timelines can be repeated, with a yoyo style option.
- Many callbacks can be specified (when tweens or timelines complete, start, end, etc.).
- Simple timers can be built with Tween.call().
- Source code extensively documented!
- Wiki documentation to get you started!
[quote]Decription page: http://www.aurelienribon.com/blog/projects/universal-tween-engine/
Google code project page: http://code.google.com/p/java-universal-tween-engine/
Download page: http://code.google.com/p/java-universal-tween-engine/downloads/list
[/quote]
I made two java applets (first one is illustrated below) to let you understand what tweens (and timelines) are, check them out