SHARE
TWEET

Untitled

a guest Sep 20th, 2014 204 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class SplashState extends State {
  2.        
  3.         private Texture tex;
  4.         private Sprite logo;
  5.         private TweenManager tm;
  6.        
  7.         public SplashState(GSM gsm) {
  8.                 super(gsm);
  9.                 Tween.registerAccessor(Sprite.class, new SpriteAccessor());
  10.                 tm = new TweenManager();
  11.                 tex = TerrereCo.res.getTexture("logo");
  12.                 logo = new Sprite(tex);
  13.                 Tween.set(logo, SpriteAccessor.ALPHA).target(0).start(tm);
  14.                 Tween.to(logo, SpriteAccessor.ALPHA, 2).target(2).repeatYoyo(1, 2).start(tm);
  15.         }
  16.  
  17.         @Override
  18.         protected void render() {
  19.                 sb.setProjectionMatrix(cam.combined);
  20.                 sb.begin();
  21.                 logo.draw(sb);
  22.                 sb.end();
  23.         }
  24.  
  25.         @Override
  26.         protected void update() {
  27.                 tm.update(Gdx.graphics.getDeltaTime());
  28.                 handleInput();
  29.                 cam.update();
  30.         }
  31.  
  32.         @Override
  33.         protected void handleInput() {
  34.                
  35.         }
  36.  
  37.  
  38. }
  39.  
  40. ==================================================================================
  41.  
  42. public class SpriteAccessor implements TweenAccessor<Sprite> {
  43.  
  44.         public static final int ALPHA = 0;
  45.        
  46.         @Override
  47.         public int getValues(Sprite target, int tweenType, float[] returnValues) {
  48.                 switch(tweenType) {
  49.                 case ALPHA:
  50.                         returnValues[0] = target.getColor().a;
  51.                         return 1;
  52.                 default:
  53.                         assert false;
  54.                         return -1;
  55.                 }
  56.         }
  57.  
  58.         @Override
  59.         public void setValues(Sprite target, int tweenType, float[] newValues) {
  60.                 switch(tweenType) {
  61.                 case ALPHA:
  62.                         target.setColor(target.getColor().r, target.getColor().g, target.getColor().b, newValues[0]);
  63.                         break;
  64.                         default:
  65.                                 assert false;
  66.                 }
  67.                
  68.         }
  69.  
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top