LibGDX。绘制多行文字 [英] LibGDX . draw multiline text

查看:144
本文介绍了LibGDX。绘制多行文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆