[lib] Universal Tween Engine

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

Re: [lib] Universal Tween Engine

Postby iainh » Fri May 25, 2012 3:02 pm

Thanks for the clear explanation! It is really helpful and saves me hours of time. :D

I may continue work on the game now.
iainh
 
Posts: 10
Joined: Mon May 14, 2012 8:15 pm

Re: [lib] Universal Tween Engine

Postby xeoshow » Tue May 14, 2013 12:24 am

Hi,

Can I use the Universal Tween Engine to do the page turning effect between 2 screens in libgdx? If yes, how? I can manage to use it to do the fadeout effect, but just not sure how to do the page turning (curl) effect...

Any help is appriaciated! Thanks.
xeoshow
 
Posts: 224
Joined: Mon Mar 18, 2013 1:12 am

Re: [lib] Universal Tween Engine

Postby ondesic » Tue May 21, 2013 8:50 pm

This engine looks great. I have searched though the wikidocs and looked at Get Started page. It seems like there are multiple ways to impliment the engine. Enough so that I am confused. I want to tween my jSprite class. My setup has the main class

Code: Select all
public class MyClass implements ApplicationListener{   
   @Override
   public void create() {      
   }

   @Override
   public void dispose() {
   }

   @Override
   public void render() {      
   }

   @Override
   public void resize(int width, int height) {
   }

   @Override
   public void pause() {
   }

   @Override
   public void resume() {
   }
}



I then have my own sprite class called jSprite:

Code: Select all
public class jSprite implements Comparable<jSprite>{
     public float x, y, width, height, scalex, scaley; ....
}


Of course this is the skeleton. Do I use TweenAccessor, Tweenable? I don't know. Others probably can, but I can't tell from the example where things are being placed. Could someone help me know where to put each part of the tween engine in my skeleton above?

Thanks so much!
ondesic
 
Posts: 33
Joined: Mon May 13, 2013 3:08 pm

Re: [lib] Universal Tween Engine

Postby semperhilaris » Wed May 29, 2013 6:36 pm

Hi onedesic,
use TweenAccessor. :)
Should look something like
Code: Select all
public class jSpriteAccessor implements TweenAccessor<jSprite> {
    public static final int TWEEN_X = 1;
   
    @Override
    public int getValues(jSprite target, int tweenType, float[] returnValues) {
        switch (tweenType) {
            case TWEEN_X: returnValues[0] = target.x; return 1;
            default: assert false; return -1;
        }
    }
   
    @Override
    public void setValues(jSprite target, int tweenType, float[] newValues) {
        switch (tweenType) {
            case TWEEN_X: target.x = newValues[0]; break;
            default: assert false; break;
        }
    }

}

That should make your x field tweenable. You can add more tween types for y, width, height, etc
Hope this helps!

regards
semperhilaris
 
Posts: 8
Joined: Sun Apr 28, 2013 12:36 pm

Re: [lib] Universal Tween Engine

Postby ondesic » Sat Jun 01, 2013 6:37 pm

Thanks so much!
ondesic
 
Posts: 33
Joined: Mon May 13, 2013 3:08 pm

Previous

Return to Libgdx Contributions

Who is online

Users browsing this forum: spriggsy and 1 guest