LibGDX . draw multiline text

你离开我真会死。 提交于 2019-12-05 01:39:50
noone

Either use \n for manual new lines and render the font via font.drawMultiLine(...).

Or use font.drawWrapped(...) with a wrap width to let libgdx wrap it automatically (manually added \n are still supported).

Update:
With libGDX 1.6 the draw methods were enhanced, and there is no further need for drawMultiLine and drawWrapped, so those were removed. Draw methods can handle multiple lines and a new boolean wrap parameter was introduced.

If you take a look at the docs, you'll see that you can use the same font.draw function, except now you're passing the target location width and whether to wrap or not.

draw(Batch batch, java.lang.CharSequence str, float x, float y, float targetWidth, int halign, boolean wrap)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!