I am new to Libgdx but with proficient knowledge in Android. I am able to place the texture in center of the screen. But when it comes to bitmapfont with the string "Level 1", I am not able to decide the width of the String and hence I am not able to place it in center of the screen.
Could you please help me to find the width/height of the Bitmapfont which has the string "Level 1"
font.getBounds() doesn't work anymore, so the answer should be updated.
You can use the following:
GlyphLayout glyphLayout = new GlyphLayout();
String item = "Example";
glyphLayout.setText(font,item);
float w = glyphLayout.width;
and use w to center with respect to a position
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With