High performance and lightweight Animation/Tween framework for Java 6+
 
 
Go to file
Robinson df404b86f4
version 9.2
2023-11-23 11:33:55 +01:00
gradle/wrapper updated gradle 2023-08-20 13:28:57 +02:00
src/dorkbox/tweenEngine version 9.2 2023-11-23 11:33:55 +01:00
src9 added jpms support 2023-01-29 14:26:11 +01:00
test Updated documentation and copyright. 2023-11-23 11:23:10 +01:00
.gitignore Updated to use Gradle Utils for gradle/project update management 2019-05-13 15:18:32 +02:00
LICENSE version 9.1 2023-08-20 13:30:48 +02:00
LICENSE.Apachev2 WIP GWT, added java-library. updated license info 2018-08-20 00:41:32 +02:00
LICENSE.CC0 added cc0 license 2023-01-29 13:41:57 +01:00
LICENSE.MIT updated license 2023-08-20 13:57:18 +02:00
README.md version 9.2 2023-11-23 11:33:55 +01:00
build.gradle.kts version 9.2 2023-11-23 11:33:55 +01:00
gradle.properties WIP conversion to kotlin 2023-01-24 21:56:01 +01:00
gradlew updated gradle 2023-08-20 13:28:57 +02:00
gradlew.bat updated gradle 2023-08-20 13:28:57 +02:00
settings.gradle.kts Hardcoded project name 2023-08-07 17:23:22 -06:00

README.md

logo

Forked from JavaUniversalTweenEngine, by Aurelien Ribon

Dorkbox Github Gitlab

Check out the demo!

Changelog

See the Changelog page.

Introduction

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:

  • 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.
  • Any attribute 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.
  • Delays can be specified, to trigger the interpolation only after some time.
  • Many callbacks can be specified (when tweens complete, start, end, etc.).
  • Tweens and Timelines are pooled - there won't be any object allocation during runtime! You can safely use it in Android game development without fearing the garbage collector.
  • Tweens can be sequenced when used in Timelines.
  • Tweens can be run in parallel when used in 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 have their "current" position (as a percentage) specified.
  • Tweens and Timelines can be repeated, and can automatically auto-reverse for a smooth "back-and-forth" animation.
  • Simple timers can be built with Tween.call().
  • Source code extensively documented!
  • All Tweens and Timelines are ThreadSafe.

Get started and documentation index

Detailed documentation with code snippets and examples is available for the following topics:

Where can I ask for help?

Use github issues

   

Maven Info

<dependencies>
    ...
    <dependency>
      <groupId>com.dorkbox</groupId>
      <artifactId>TweenEngine</artifactId>
      <version>9.2</version>
    </dependency>
</dependencies>

Gradle Info

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/

License

This project is © 2015 dorkbox llc, and is distributed under the terms of the Apache v2.0 License. See file "LICENSE" for further references.