Universal Tween Engine

Introduction
The Universal Tween Engine enables the interpolation of every attributes from any object in any Java project (being Swing, SWT, OpenGL or even console-based). A tween is a static animation running for a fixed amount of time. Therefore, tweens are perfect candidates to animate your UIs, splash screens, and all the static animations of your characters. A tween can animate anything: position, rotation, opacity, color, scale, etc. The only limitation of the tween engine is your imagination.
Demos
- Android application
- Desktop application (stand-alone executable)
- HTML5 page (requires a WebGL enabled browser, like Chrome)
Features
- 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!
The engine is mainly divided into Tweens and Timelines.
Tweens
Tweens are small one-line statements that let you start the animation of one or multiple attributes of an object. Better than a thousand lines of text, take a look at the following demo applet (link on the right). Don’t hesitate to change the easing function, and to add repetitions to your animation.
In this demonstration, we only use tween to animate the position of an object. However, when using the Tween Engine, you describe what you want to animate, so everything is possible. To start a tween, only thing needed is:
// Animation of an object position to the coordinates (100,200), in one second Tween.to(myobject, Type.POSITION, 1.0f).target(100, 200).start(myManager);
Many options are available to customize the animation:
Tween.to(myobject, Type.POSITION, 1.0f)
.targetRelative(10, -20) // the target can be relative to the current values
.delay(2.5f) // a delay can be specified
.ease(Quad.OUT) // the easing function can be modified
.repeat(2, 0.5f) // repetitions are possible
.repeatYoyo(2, 0.5f) // yoyo repetitions too (one play forward, the other backward, etc)
.setUserData(obj) // custom objects can be attached
.setCallback(cb) // callbacks can be specified to get notified of the completion
.setCallbackTriggers(...) // callbacks can be launched on many events, not just completion
.start(myManager);
A tween is based on precise timings, as follows:
A tween under normal playing. It may start with a delay, and can be repeated any number of times (with an optional delay between repetitions).
Callbacks are very important, and let you trigger actions on precise events. There are callbacks for forward playing, and for backward playing:
You can get notified of many events, both during forward play and backward play!
Timelines
Timelines let you create powerful sequences of multiple tweens. They will be automatically delayed to be executed one after the other. See the following demo applet on the right.
Creating sequences is easy, just stack .push() calls! You can also nest timelines into other timelines.
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!
The options of timelines are the same as the ones for tweens, including repetitions and callbacks! What was possible for tweens is also possible for timelines.
Download binaries and source code
The project is fully open-source, and currently hosted at Google Code using a Mercurial repository. Each time a revision is considered stable, it is released as a binary package.
Project page: http://code.google.com/p/java-universal-tween-engine/
Download page: http://code.google.com/p/java-universal-tween-engine/downloads/list
Get started
A detailed example is provided in the project wiki:
http://code.google.com/p/java-universal-tween-engine/wiki/GetStarted
Also, you may want to take a look at the source code of the demo:
http://code.google.com/p/java-universal-tween-engine/source/browse/#hg%2Ftween-engine-tests%2Fsrc%2Faurelienribon%2Ftweenengine%2Ftests
Javadoc
Sources for the library are shared within the zip file. Linking to them in your favorite IDE (eclipse, netbeans, idea) will let you access the javadocs directly from the editor itself.
Support
If you spotted a bug, or have a great improvement idea, feel free to submit it to the Issue Tracker.
For any other information, there is a dedicated forum for you.

[...] in order to present the library to new users, I wrote a new page dedicated to it (also available by clicking on its banner on the front page of this blog). The page features two [...]
Hi,
Version 6.2.0:
– No more .size() on TweenManager?
Cheers
Hello. I removed it since its behavior was not coherent with its definition, but I’m planning to reintroduce it in a different way.
Hi,
I am trying to build an app and facing issues with the delay and Timeline. Are there any constraints on the delay time values?
Anyways, I cant get the timeline working. Any suggestions?
Thanks
Well, I can’t really help you with your description of the issue :p
One of the most common fix: are you sure all your timings use consistent time unit? I mean if the duration of a tween is expressed in milliseconds, then the duration of the delays and all other timings have to be expressed in milliseconds.
I’ll try to setup a forum so you can explain your issue furthermore. Before that, send me a mail ;)
can you please make the android demo application’s code be available – it will help me to understand the implementations and get me started to zoom in and zoom out the layouts. thanks
It’s already available: http://code.google.com/p/java-universal-tween-engine/source/browse/#hg%2Ftween-engine-tests%2Fsrc%2Faurelienribon%2Ftweenengine%2Fdemo
Hey there,
i am making a subtitling system in java.. i want my subtitles to have tweens like to make it bounce and stuff which i can later import..
is it possible to get tweens on ur text using this engine??
thanks!!
You can use the engine on everything, everywhere, that’s the spirit :)
If you need help, make a post in the forum with code exctracts of what you’re trying to do.
Hey there.. quick question.. after adding tweens to the text i want to save the file as a subtitle file(.srt).. would the tweens be still there..??
as far as i found.. (.srt) wouldn support animation..
on the other hand .ass(advanced sub station aplha ) is used for more advanced metadata would that help?
Thanks
[...] Universal Tween Engine integration with some Tweeners built in. [...]
I have problems getting the JavaDoc to work on an Android project. I tried to add the sources.jar to the Java Build Path, but I had no luck.
Can you guide me please?
You need to attach the sources, not to add them to the build path. Look at this topic, it will teach you how to do this: http://stackoverflow.com/questions/122160/is-there-an-easy-way-to-attach-source-in-eclipse
[...] silnika gry użyto Uniwersal Tween Engine, który odpowiada za animowanie elementów dekoracyjnych oraz animację samego robaczka. Biblioteka [...]
[...] silnika gry użyto Uniwersal Tween Engine, który odpowiada za animowanie elementów dekoracyjnych oraz animację samego robaczka. Biblioteka [...]
[...] la police de caractère avec Font Forge les sons avec Audacity, l’animation avec Universal Tween Engine et le moteur global du jeu avec Libgdx Le tout sous [...]
ekafwbvsfmjfosjcpo, Kamagra oral jelly uk, RGDOXMV, [url=http://ukkamagraoraljelly.com/]Kamagra oral jelly slovenia[/url], eKpmHpr, http://ukkamagraoraljelly.com/ Kamagra 100 mg oral jelly sachets, SjTUCjG.
Hi!
I’ve been reading your site for some time now and finally got the courage to go ahead and give you a shout out! Just wanted to tell you keep up the good work!
More to come on my webpage Wendi