0

I am trying to make a bitmapfont exactly in the middle of the screen however it starts the the whole text in the middle and doesn't center it. I can't guess and check because that won't work for all resolutions. I tried doing xCoor / 2 but like I said that would start the first letter in the center and won't center the full text

Is there a way to find the exact width of a string of text in libgdx?

Martin Thorsen Ranang
  • 2,394
  • 1
  • 28
  • 43
Pookie
  • 1,239
  • 1
  • 14
  • 44
  • See also this [SO question](http://stackoverflow.com/questions/16600547/how-get-a-string-width-in-libgdx) and this [GameDev question](http://gamedev.stackexchange.com/questions/45777/bitmap-font-displays-in-center-always-without-coding-it-manually-fix-coordinate). – Mephy Oct 06 '15 at 00:41
  • Right answer is linked in @mephy 's first comment but approved answer in it won't work because it's deprecated. You need to use second answer in which uses newer GlyphLayout. direct link: http://stackoverflow.com/a/30392036/2517120 – Burak Kurkcu Oct 06 '15 at 00:55

0 Answers0