Quantcast
Channel: Question and Answer » libgdx
Viewing all articles
Browse latest Browse all 434

LibGdx TextButtonStyle Offset not working correctly

$
0
0

I’m intending to give an animation to the TextButton by giving the pressedOffsetX and pressedOffsetY values:

TextButtonStyle buttonStyle = new TextButtonStyle();
buttonStyle.font = font25;
buttonStyle.fontColor = Color.WHITE;
buttonStyle.up = new TextureRegionDrawable(settingsAtlas.findRegion("achievements"));
buttonStyle.down = new TextureRegionDrawable(settingsAtlas.findRegion("achievements"));
buttonStyle.pressedOffsetX = 5;
buttonStyle.pressedOffsetY = -5;

And I created a button like this:

TextButton achievementsButton = new TextButton("ACHIEVEMENTS", buttonStyle);
achievementsButton.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
        // show achievements
    }
});

But when I click the button, only the text in it is animated. The button background stays in the same position. What might I be doing wrong here?


Viewing all articles
Browse latest Browse all 434

Trending Articles