Skip to content
May 2, 2011 / Aurélien Ribon

Universal Tween Engine: rev 4.2

Hi there,

I released a new version of the Tween Engine. It mostly features facilities to handle overwriting tweens.

Changelog:

+ Added “boolean contains(Tweenable target)” to TweenManager.java
+ Added “boolean contains(Tweenable target, int tweenType)” to TweenManager.java
+ Added “void kill(Tweenable target)” to TweenManager.java
+ Added “void kill(Tweenable target, int tweenType)” to TweenManager.java
+ Added “Tween[] getTweens(Tweenable target)” to TweenManager.java
+ Added “Tween[] getTweens(Tweenable target, int tweenType)” to TweenManager.java

http://code.google.com/p/java-universal-tween-engine/

It is now easy to manually manage overwriting tweens. I tried to add an automatic support for overwrites, but I always found corner-cases in my own games where such automatic management would be more a pain than a gift. Therefore, I removed it.

Usage example:

// 1. Kill every tween associated to a type used in the
//    sequence below.

tweenManager.kill(tweenSprite, TweenSprite.ROTATION);
tweenManager.kill(tweenSprite, TweenSprite.OPACITY);
tweenManager.kill(tweenSprite, TweenSprite.POSITION_XY);
tweenManager.kill(tweenSprite, TweenSprite.SCALE_XY);

// 2. Add the new sequence safely.

tweenManager.add(new TweenGroup().pack(
	Tween.set(tweenSprite, TweenSprite.ROTATION)...,
	Tween.set(tweenSprite, TweenSprite.OPACITY)...,
	Tween.set(tweenSprite, TweenSprite.POSITION_XY)...,
	Tween.set(tweenSprite, TweenSprite.SCALE_XY)...,
	Tween.to(tweenSprite, TweenSprite.OPACITY, 1000, Sine.INOUT)...,
	Tween.to(tweenSprite, TweenSprite.SCALE_XY, 1000, Quart.INOUT)...,
	Tween.to(tweenSprite, TweenSprite.POSITION_XY, 1000, Elastic.OUT)...,
	Tween.to(tweenSprite, TweenSprite.ROTATION, 800, Cubic.INOUT)...
).sequence().start());

Tell me if you need other methods. I wondered if I should add some overloads to the methods from the changelog, in order to handle more than one tween type at once. However, that would require variable arguments, and thus allocation. I could also go the flag way, but tween types would need to be powers of two…

Anyway, have fun with this release :)

PS: someone in the tween engine google group asked me how to add tween support to a java Swing GUI. The test executable now provides such feature, as well as the game example. I still need to produce a real eye-candy demo with the game backend :)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s