My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
howto  
how to use sumotween
Updated Sep 7, 2010 by thomas.k...@gmail.com

simple animation

this example shows how this simple animation is done:

initialize a tweener:

testTween=new Tweener();                    // create new tweener
testTween.setEasing(new Cubic());           // set the default easing mode to cubic

testTween.set(0, 10f, Tweener.EASING_IN);   // create key at time 0, with value 10, easing mode "in"
testTween.set(1, 100f, Tweener.EASING_OUT); // using easing mode "out" to slow down the animation.
testTween.set(2, 10f);                      // the animation will end at y-position 10

this is how the rendering is done:

g.fillRect(60,testTween.getIntValue(), 10, 10);

.getIntValue() returns the current value as an integer. it is used as the y position of the rectangle.


restarting an animation

you can reset the timer of a tweener using .resetTimer():

testTween.resetTimer();

you can use key events to automaticaly restart the animation.


adding keys "on the fly"

you can set the time of a key relative. e.g. add a key in one second with the value 100

testTween.add(1f, 100f);


using events

keyevents are triggered when the time of key is reached.

testTween.set(1, 100f, Tweener.EASING_OUT, new Cubic(), new KeyEvent() 
{
  public void KeyEvent(KeyFloat keyFloat) 
  {
    System.out.println("key is active! ");
  }
});

Sign in to add a comment
Powered by Google Project Hosting