Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a TweenMax equivalent in Java

I'm still relatively new to Java and Android development, so I'm still unfamiliar with the multitudes of libraries available for use, particularly for animation. Where I'm from (the Flash world), we have access to several 3rd-party tweening engines that make life very easy for us when we want to programmatically move things around the stage without relying on the (vastly inferior) built-in Adobe tween APIs. One of the most popular is Greensock's TweenMax

Looking at the way Android handles tweening natively, it appears to be very cumbersome compared to what I'm used to. I'm curious if there's a TweenMax-equivalent library out there for Android that makes animation sequencing equally easy to write in-code, with the benefits of smart intellisense, rather than having to write them all out in an external animation.xml file in the res folder.

like image 456
scriptocalypse Avatar asked Jan 21 '23 12:01

scriptocalypse


2 Answers

Sorry to reply so lately to this thread, but there is a more framework-independent answer to your question: the java Universal Tween Engine.

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

enter image description here

This library started as a way to mimic TweenMax/Lite functionality in any java project, and ended as a complete, independent, tweening engine. It is optimized for Android (no dynamic allocation), but can be used in virtually every java project, being a Swing UI or an OpenGL game...

You shouldn't be lost if you come from TweenMax world, since the base syntax is quite similar:

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

Timelines are a bit different though, but are still easy to understand:

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);

Hope that helps :)

like image 136
Aurelien Ribon Avatar answered Jan 28 '23 16:01

Aurelien Ribon


You don't have to use XML files, you can use Animation, AnimationSet and the various Interpolator implementations. Android 3.0 however provides a much more powerful animation API.

like image 28
Romain Guy Avatar answered Jan 28 '23 18:01

Romain Guy