Forked from JavaUniversalTweenEngine, by Aurelien Ribon
See the Changelog page.
The Tween Engine enables the interpolation of every attribute from any object in any Java project (being Swing, SWT, OpenGL or even Console-based). Implement the TweenAccessor interface, register it to the engine, and animate anything you want!
In one line, send your objects to another position (here x=20 and y=30), with a smooth elastic transition, during 1 second).
val engine = TweenEngine.build()
// Arguments are (1) the target, (2) the type of interpolation,
// and (3) the duration in seconds. Additional methods specify
// the target values, and the easing function.
engine.to(mySprite, Type.POSITION_XY, 1.0f).value(20, 30).ease(Elastic.INOUT);
// Possibilities are:
myTween = engine.to(...); // interpolates from the current values to the targets
myTween = engine.from(...); // interpolates from the given values to the current ones
myTween = engine.set(...); // apply the target values without animation (useful with a delay)
myTween = engine.call(...); // calls a method (useful with a delay)
// Current options are:
callback.setTriggers(flags);
myTween.delay(0.5f);
myTween.repeat(2, 0.5f);
myTween.repeatAutoReverse(2, 0.5f);
myTween.pause();
myTween.resume();
myTween.addCallback(callback);
myTween.setUserData(obj);
// You can of course chain everything:
engine.to(...).delay(1.0f).repeat(2, 0.5f).start();
// Moreover, slow-motion, fast-motion and reverse play is easy,
// you just need to change the speed of the update:
engine.update(delta * speed);
Create some powerful animation sequences!
val engine = TweenEngine.build()
engine.createSequence()
// First, set all objects to their initial positions
.push(engine.set(...))
.push(engine.set(...))
.push(engine.set(...))
// Wait 1s
.pushPause(1.0f)
// Move the objects around, one after the other
.push(engine.to(...))
.push(engine.to(...))
.push(engine.to(...))
// Then, move the objects around at the same time
.beginParallel()
.push(engine.to(...))
.push(engine.to(...))
.push(engine.to(...))
.end()
// And repeat the whole sequence 2 times
// with a 0.5s pause between each iteration
.repeatAutoReverse(2, 0.5f)
// Let's go!
.start();
You can also quickly create timers:
TweenEngine.build().call(myCallback).delay(3000).start();
Main features are:
Detailed documentation with code snippets and examples is available for the following topics:
Use github issues
<dependencies>
...
<dependency>
<groupId>com.dorkbox</groupId>
<artifactId>TweenEngine</artifactId>
<version>9.2</version>
</dependency>
</dependencies>
dependencies {
...
compile "com.dorkbox:TweenEngine:8.3"
}
Or if you don't want to use Maven, you can access the files directly here:
https://repo1.maven.org/maven2/com/dorkbox/TweenEngine/
https://repo1.maven.org/maven2/com/dorkbox/ObjectPool/
https://repo1.maven.org/maven2/org/slf4j/slf4j-api/
This project is © 2015 dorkbox llc, and is distributed under the terms of the Apache v2.0 License. See file "LICENSE" for further references.