# Renderd7-nightly: TweenEngine Namespace Reference

TweenEngine Namespace Reference

## Detailed Description

BaseTween is the base class of Tween and Timeline. It defines the iteration engine used to play animations for any number of times, and in any direction, at any speed.

It is responsible for calling the different callbacks at the right moments, and for making sure that every callbacks are triggered, even if the update engine gets a big delta time at once.

See also
  Tween
  Timeline

Author
  Aurelien Ribon | http://www.aurelienribon.com/

A light pool of objects that can be resused to avoid allocation. Based on Nathan Sweet pool implementation

Base class for every easing equation. You can create your own equations and directly use them in the Tween engine by inheriting from this class.

See also
  Tween

Author
  Aurelien Ribon | http://www.aurelienribon.com/

A TweenManager updates all your tweens and timelines at once. Its main interest is that it handles the tween/timeline life-cycles for you, as well as the pooling constraints (if object pooling is enabled).

Just give it a bunch of tweens or timelines and call update() periodically, you don't need to care for anything else! Relax and enjoy your animations.

See also
  Tween
  Timeline

Author
  Aurelien Ribon | http://www.aurelienribon.com/

Base class for every paths. You can create your own paths and directly use them in the Tween engine by inheriting from this class.

Author
  Aurelien Ribon | http://www.aurelienribon.com/

Easing equation based on Robert Penner's work: http://robertpenner.com/easing/

Author
  Aurelien Ribon | http://www.aurelienribon.com/

Core class of the Tween Engine. A Tween is basically an interpolation between two values of an object attribute. However, the main interest of a Tween is that you can apply an easing formula on this interpolation, in order to smooth the transitions or to achieve cool effects like springs or bounces.

The Universal Tween Engine is called "universal" because it is able to apply interpolations on every attribute from every possible object. Therefore, every object in your application can be animated with cool effects: it does not matter if your application is a game, a desktop interface or even a console program! If it makes sense to animate something, then it can be animated through this engine.

This class contains many static factory methods to create and instantiate new interpolations easily. The common way to create a Tween is by using one of these factories:

- Tween.to(...)
- Tween.from(...)
- Tween.set(...)
- Tween.call(...)

## Example - firing a Tween

The following example will move the target horizontal position from its current value to x=200 and y=300, during 500ms, but only after a delay of 1000ms. The animation will also be repeated 2 times (the starting position is registered at the end of the delay, so the animation will automatically restart from this registered position).

    Tween.to(myObject, POSITION_XY, 0.5f)
         .target(200, 300)
         .ease(Quad.INOUT)
         .delay(1.0f)
         .repeat(2, 0.2f)
         .start(myManager);

Tween life-cycles can be automatically managed for you, thanks to the TweenManager class. If you choose to manage your tween when you start it, then you don't need to care about it anymore. Tweens are fire-and-forget: don't think about them anymore once you started them (if they are managed of course).

You need to periodicaly update the tween engine, in order to compute the new values. If your tweens are managed, only update the manager; else you need to call update() on your tweens periodically.

## Example - setting up the engine

The engine cannot directly change your objects attributes, since it doesn't know them. Therefore, you need to tell him how to get and set the different attributes of your objects: you need to implement the {} interface for each object class you will animate. Once done, don't forget to register these implementations, using the static method registerAccessor()}, when you start your application. TweenAccessor TweenManager TweenEquation Timeline Aurelien Ribon | http://www.aurelienribon.com/