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