Skip to content

Instantly share code, notes, and snippets.

@pplante
Created February 3, 2012 06:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pplante/1728474 to your computer and use it in GitHub Desktop.
Save pplante/1728474 to your computer and use it in GitHub Desktop.
import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.TweenAccessor;
import com.unhappyrobot.entities.GameObject;
public class GameObjectAccessor implements TweenAccessor<GameObject> {
static {
Tween.registerAccessor(GameObject.class, new GameObjectAccessor());
}
public static final int POSITION = 1;
public static final int OPACITY = 2;
public int getValues(GameObject target, int tweenType, float[] returnValues) {
switch (tweenType) {
case OPACITY:
returnValues[0] = target.getOpacity();
return 1;
case POSITION:
returnValues[0] = target.getPosition().x;
returnValues[1] = target.getPosition().y;
return 2;
default:
assert false;
return 0;
}
}
public void setValues(GameObject target, int tweenType, float[] newValues) {
switch (tweenType) {
case OPACITY:
target.setOpacity(newValues[0]);
break;
case POSITION:
target.setPosition(newValues[0], newValues[1]);
break;
default:
assert false;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment