Label not properly centered in TextButton

Posted by Kees de Bruin on Game Development See other posts from Game Development or by Kees de Bruin
Published on 2014-06-10T09:49:34Z Indexed on 2014/06/10 15:43 UTC
Read the original article Hit count: 184

Filed under:

I'm using LibGDX v1.1.0 and I see that the label of a TextButton is not properly centered. I have the following code:

m_resumeButton = new TextButton("resume", skin);
m_resumeButton.addListener(new ChangeListener() {
    public void changed(ChangeEvent event, Actor actor) {
        m_state = GameState.RUNNING;
        getGame().getWorld().pauseWorld(false);
    }
});

The default TextButtonStyle is defined as:

"com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle": {
    "default": {
        "up": "menu-button", 
        "down": "menu-button-down", 
        "checked": "menu-button-down", 
        "disabled": "menu-button-disabled", 
        "font": "font24", 
        "fontColor": "white"
    }
}

The menu button images are simple 240x48 bitmaps saved as 9-patch images. An image can be found here to illustrate the problem:

https://www.dropbox.com/s/cwuhu5xb9ro5w6m/screenshot001.jpg

Am I doing something wrong? Or is there a problem with the button images I'm using?

© Game Development or respective owner

Related posts about libgdx