2017-02-21 17 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