2017-02-21 16 views

回答

1

BitmapFontCache,缓存BitmapFont的字形几何体。

BitmapFont bitmapFont=new BitmapFont(); 
BitmapFontCache bitmapFontCache=new BitmapFontCache(bitmapFont); 

BitmapFontCache setColors (float color, int start, int end)有设置指定字符颜色的方法。

+0

谢谢你的作品。有没有可能如何将此BitmapFontCache设置为标签?所以,我想为文本添加一个Actions.moveTo()效果,因此我实际上需要一个标签。我怎样才能做到这一点? – erik4thewinners

1

我强烈建议你使用颜色标记语言,这是内置到LibGDX。

你只需要启用这样的标记语言:

BitmapFont font = myfont; 
font.getData().markupEnabled = true; 

那么简单的格式文本如下:

String text = "[RED]My test string[]" 

这也适用于标签:)

还不错阅读这个主题:https://github.com/libgdx/libgdx/wiki/Color-Markup-Language