• Home
Name Date Size #Lines LOC

..--

java/03-May-2024-5,5773,672

Android.mkD03-May-2024823 256

LICENSED03-May-202411.1 KiB203169

README.mdD03-May-20244.6 KiB11987

README.md

1![](http://www.aurelienribon.com/blog/wp-content/uploads/2012/05/tween-engine-big-logo.jpg)
2
3## Check out the demo!
4
5  * [Android application](https://play.google.com/store/apps/details?id=aurelienribon.tweenengine.demo)
6  * [Desktop application](http://code.google.com/p/java-universal-tween-engine/downloads/detail?name=tween-engine-demo-6.3.0.zip)
7  * [WebGL html5 page](http://www.aurelienribon.com/universal-tween-engine/gwt/demo.html) (requires a WebGL enabled browser)
8
9## Introduction
10
11The Universal 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!
12
13In one line, send your objects to another position (here x=20 and y=30), with a smooth elastic transition, during 1 second).
14
15```java
16// Arguments are (1) the target, (2) the type of interpolation,
17// and (3) the duration in seconds. Additional methods specify
18// the target values, and the easing function.
19
20Tween.to(mySprite, Type.POSITION_XY, 1.0f).target(20, 30).ease(Elastic.INOUT);
21
22// Possibilities are:
23
24Tween.to(...); // interpolates from the current values to the targets
25Tween.from(...); // interpolates from the given values to the current ones
26Tween.set(...); // apply the target values without animation (useful with a delay)
27Tween.call(...); // calls a method (useful with a delay)
28
29// Current options are:
30
31myTween.delay(0.5f);
32myTween.repeat(2, 0.5f);
33myTween.repeatYoyo(2, 0.5f);
34myTween.pause();
35myTween.resume();
36myTween.setCallback(callback);
37myTween.setCallbackTriggers(flags);
38myTween.setUserData(obj);
39
40// You can of course chain everything:
41
42Tween.to(...).delay(1.0f).repeat(2, 0.5f).start(myManager);
43
44// Moreover, slow-motion, fast-motion and reverse play is easy,
45// you just need to change the speed of the update:
46
47myManager.update(delta * speed);
48```
49
50Create some powerful animation sequences!
51
52```java
53Timeline.createSequence()
54    // First, set all objects to their initial positions
55    .push(Tween.set(...))
56    .push(Tween.set(...))
57    .push(Tween.set(...))
58
59    // Wait 1s
60    .pushPause(1.0f)
61
62    // Move the objects around, one after the other
63    .push(Tween.to(...))
64    .push(Tween.to(...))
65    .push(Tween.to(...))
66
67    // Then, move the objects around at the same time
68    .beginParallel()
69        .push(Tween.to(...))
70        .push(Tween.to(...))
71        .push(Tween.to(...))
72    .end()
73
74    // And repeat the whole sequence 2 times
75    // with a 0.5s pause between each iteration
76    .repeatYoyo(2, 0.5f)
77
78    // Let's go!
79    .start(myManager);
80```
81
82You can also quickly create timers:
83
84```java
85Tween.call(myCallback).delay(3000).start(myManager);
86```
87
88Main features are:
89
90  * Supports every interpolation function defined by [Robert Penner](http://www.robertpenner.com/easing/).
91  * Can be used with any object. You just have to implement the TweenAccessor interface when you want interpolation capacities.
92  * Every attribute can be interpolated. The only requirement is that what you want to interpolate can be represented as a float number.
93  * One line is sufficient to create and start a simple interpolation.
94  * Delays can be specified, to trigger the interpolation only after some time.
95  * Many callbacks can be specified (when tweens complete, start, end, etc.).
96  * Tweens and Timelines are pooled by default. If enabled, there won't be any object allocation during runtime! You can safely use it in Android game development without fearing the garbage collector.
97  * Tweens can be sequenced when used in Timelines.
98  * 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 !
99  * Tweens and Timelines can be repeated, with a yoyo style option.
100  * Simple timers can be built with Tween.call().
101  * **Source code extensively documented!**
102
103## Get started and documentation index
104
105Detailed documentation with code snippets and examples is available for the following topics:
106  * Get started --- A step-by-step example to get you started, with code
107
108  * The TweenAccessor interface --- Know how to implement it
109  * Tweens and options --- See what are the possibilities
110  * Timelines and options --- Learn how to build powerful sequences
111  * Animating Android apps --- See how to use the engine with Android UIs
112
113## Where can I ask for help?
114
115There is a dedicated forum for you:
116http://www.aurelienribon.com/forum/viewforum.php?f=5
117
118Also, the following link will guide you to a discussion thread that started it all:
119http://www.badlogicgames.com/forum/viewtopic.php?f=17&t=494