LibGDX。绘制多行文字 [英] LibGDX . draw multiline text
问题描述
我试图在libGDX中使用BitmapFont编写一个大文本。但它显示在一行上,用户只能看到文本的第一部分。如何使bitmapFont自动创建新行并在屏幕上显示整个文本?
I am trying to write a big text using BitmapFont in libGDX . But it shows on one line and the user can see only the first part of the text . How can I make that bitmapFont made new line automatically and show whole text on the screen ?
推荐答案
使用 \ n
获取手动换行并渲染字体来自 font.drawMultiLine(...)
。
Either use \n
for manual new lines and render the font via font.drawMultiLine(...)
.
或使用 font.drawWrapped(...)
使用换行宽度让libgdx自动换行(仍然支持手动添加 \ n
)。
更新:
使用libGDX 1.6,绘制方法得到增强,并且不再需要drawMultiLine和drawWra pped,所以那些被删除。 Draw方法可以处理多行和一个新的 boolean wrap 参数。
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.
这篇关于LibGDX。绘制多行文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!