Hi Nate! Sorry for late reply!
Code above doesn't work for me. But it's ok, i'll use static images )
Maybe you'll help with another issue.. I wanna make button row with spine actors below the scrolling images:
//Scroll
scrollPane = new PlaneScrollPane(imagesTable);
scrollPane.setScrollingDisabled(false, true);
// Buttons
Table buttons = new Table();
FrameButton fb = new FrameButton();
buttons.add(fb).size(70);
container.add(scrollPane);
container.row();
container.add(buttons);
stage.addActor(container);
I see the button in center of row in debug mode and when press animation works fine, BUT the actor (image) is at 0,0 position of the stage. Tried to modify setPosition(200, 200) - it doesn't react - all the same at 0, 0.
Here the actor's code:
public class FrameButton extends Actor {
public Skeleton getSkeleton() {
return skeleton;
}
private Skeleton skeleton;
private SkeletonRenderer skeletonRenderer;
private AnimationState animationState;
public FrameButton() {
setPosition(200, 200);
setWidth(70);
setHeight(70);
loadAnimation();
addListener(listener);
}
private void loadAnimation() {
SkeletonJson json = new SkeletonJson(HaresAssets.img_atlas_actors);
SkeletonData data = json.readSkeletonData(Gdx.files.internal("data/animation/button.json"));
AnimationStateData stateData = new AnimationStateData(data);
animationState = new AnimationState(stateData);
skeleton = new Skeleton(data);
skeleton.setToSetupPose();
skeleton.updateWorldTransform();
skeletonRenderer = new SkeletonRenderer();
}
@Override
public void act(float delta) {
skeleton.setX(getX() + getWidth() / 2);
skeleton.setY(getY());
skeleton.update(delta);
skeleton.updateWorldTransform();
animationState.update(delta);
animationState.apply(skeleton);
super.act(delta);
}
@Override
public void draw(SpriteBatch batch, float parentAlpha) {
skeleton.getColor().a = parentAlpha;
skeletonRenderer.draw(batch, skeleton);
super.draw(batch, parentAlpha);
}
InputListener listener = new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
animationState.setAnimation(0, "press", false);
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
super.touchUp(event, x, y, pointer, button);
}
};
}