我用 Java 构建了一个通用的 Tween 引擎,你可以用它来动画任何东西,包括你的精灵。它针对 Android 和游戏进行了优化,因为它在运行时不分配任何东西,以避免任何垃圾收集。此外,Tweens 是池化的,所以真的:根本没有垃圾收集!
你可以在这里看到一个完整的演示作为一个 android 应用程序,或者在这里作为一个 WebGL html 页面(需要 Chrome)!
您所要做的就是实现TweenAccessor
接口以将 Tween 支持添加到所有精灵。您甚至不必更改 Sprite 类,只需创建一个SpriteTweenAccessor
实现 的类TweenAccessor<Sprite>
,并在初始化时将其注册到引擎。看看GetStarted wiki 页面;)
http://code.google.com/p/java-universal-tween-engine/

我还在构建一个可以嵌入到任何应用程序中的可视化时间线编辑器。它将具有类似于 Flash 创作工具和 Expression Blend(Silverlight 开发工具)的时间线。
整个引擎有大量文档(所有公共方法和类都有详细的 javadoc),语法与 Flash 世界中使用的 Greensock 的 TweenMax/TweenLite 引擎非常相似。请注意,它支持每个 Robert Penner 缓动方程。
// 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.
Tween.to(mySprite, Type.POSITION_XY, 1.0f).target(50, 50).ease(Elastic.INOUT);
// Possibilities are:
Tween.to(...); // interpolates from the current values to the targets
Tween.from(...); // interpolates from the given values to the current ones
Tween.set(...); // apply the target values without animation (useful with a delay)
Tween.call(...); // calls a method (useful with a delay)
// Current options are:
yourTween.delay(0.5f);
yourTween.repeat(2, 0.5f);
yourTween.repeatYoyo(2, 0.5f);
yourTween.pause();
yourTween.resume();
yourTween.setCallback(callback);
yourTween.setCallbackTriggers(flags);
yourTween.setUserData(obj);
// You can of course chain everything:
Tween.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:
yourTween.update(delta * speed);
当然,如果不提供构建强大序列的方法,任何补间引擎都是不完整的 :)
Timeline.createSequence()
// First, set all objects to their initial positions
.push(Tween.set(...))
.push(Tween.set(...))
.push(Tween.set(...))
// Wait 1s
.pushPause(1.0f)
// Move the objects around, one after the other
.push(Tween.to(...))
.push(Tween.to(...))
.push(Tween.to(...))
// Then, move the objects around at the same time
.beginParallel()
.push(Tween.to(...))
.push(Tween.to(...))
.push(Tween.to(...))
.end()
// And repeat the whole sequence 2 times
// with a 0.5s pause between each iteration
.repeatYoyo(2, 0.5f)
// Let's go!
.start();
我希望你相信 :) 很多人已经在他们的游戏中使用这个引擎或用于 android UI 动画。