Java中是否存在TweenMax等效项

时间:2011-02-10 23:29:22

标签: java android flash actionscript-3 animation

我仍然相对较新的Java和Android开发,所以我仍然不熟悉可用的大量库,特别是动画。我来自(Flash世界),我们可以访问几个第三方补间引擎,当我们想要以编程方式在舞台上移动东西而不依赖于(极其低劣的)内置Adobe时,我们的生活非常轻松补间API。其中最受欢迎的是Greensock的TweenMax

看看Android处理本地补间的方式,与我以前相比,它看起来非常麻烦。我很好奇是否有适用于Android的TweenMax等效库,这使得动画排序在代码中同样易于编写,具有智能智能感知的优点,而不必将其全部写入外部animation.xml文件中res文件夹。

3 个答案:

答案 0 :(得分:7)

很抱歉最近回复了这个帖子,但是你的问题还有一个更独立于框架的答案:java Universal Tween Engine。

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

enter image description here

这个库最初是为了模仿任何java项目中的TweenMax / Lite功能,并以一个完整的,独立的补间引擎结束。它针对 Android 进行了优化(无动态分配),但几乎可用于所有Java项目,包括 Swing UI OpenGL游戏 ...

如果你来自TweenMax世界,你不应该迷失,因为基本语法非常相似:

Tween.to(myObject, POSITION, 1000).target(20, 30).ease(Elastic.OUT).start(myManager);

时间轴虽然有点不同,但仍然很容易理解:

Timeline.createSequence()
    // First, set all objects to their initial positions
    .push(Tween.set(...))
    .push(Tween.set(...))
    .push(Tween.set(...))

    // Wait 1s
    .pushPause(1000)

    // 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
    .repeatYoyo(2, 500)

    // Let's go!
    .start(myManager);

希望有所帮助:)

答案 1 :(得分:1)

您不必使用XML文件,您可以使用Animation,AnimationSet和各种Interpolator实现。然而,Android 3.0提供了更强大的动画API。

答案 2 :(得分:1)

实际上,我认为我发现了一些接近我要求的东西。这里有一个适用于Android的Cocos2D端口: Cocos2D for android

它不是完全没有bug(主要考虑粒子系统),但它为你使用Greensock的各种东西提供了广泛的动画和显示功能。它甚至还配备了Box2D端口。