I download newest libgdx version 1.6 and i cant solve problem with center my BitmapFont text. Earlier in version 1.54 i used getBounds() method to find out width of text.
Share your solutions, thanks
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
There was a post explaining the changes, but is not easy to find. The link was on the 1.5.6 release changelog: http://www.badlogicgames.com/wordpress/?p=3666
And the link about changes in fonts was: http://www.badlogicgames.com/wordpress/?p=3658
private static GlyphLayout glyphLayout = new GlyphLayout(); private BitmapFont fontA = new BitmapFont(), fontB = new BitmapFont(); // Set text and font each time you want to calculate bounds. glyphLayout.setText(fontA, "my string"); fontA.draw(batch, glyphLayout, x + glyphLayout.width / 3, y + glyphLayout.height / 3); y += glyphLayout.height; glyphLayout.setText(fontB, "different font"); fontB.draw(batch, glyphLayout, x + glyphLayout.width / 3, y + glyphLayout.height / 3);