我尽量让是:LibGDX:是否可以绘制一个BitmapFont并更新它?
- 在屏幕的顶部绘制BitmapFont,让它去下到谷底,在那里被删除。
- 尽管该BitmapFont仍在继续,但可以用不同的文本绘制另一个BitmapFont。
- 重复1和2
这是可以实现的一个BitmapFont或者我必须做出多个BitmapFonts为了这个工作?
编辑:
private BitmapFont font;
public PlayState(GameStateManager gsm) {
super(gsm);
cam.setToOrtho(false, Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
// TODO: change the font of the random word
font = new BitmapFont();
font.setColor(Color.BLACK);
@Override
public void render(SpriteBatch batch) {
batch.setProjectionMatrix(cam.combined);
batch.begin();
for (Rectangle word1 : word.words) {
font.draw(batch, word.getWordString(), word1.x, word1.y);
}
batch.end();
}
word.getWordString()
是我想说明,这与每一个循环改变文本。它现在所做的是改变最上面生成的新词的文本,也改变上一个词。
EDIT2:
public class Word {
public Array<Rectangle> words;
public Word(){
words = new Array<Rectangle>();
spawnWord();
}
public void spawnWord() {
Rectangle word = new Rectangle();
word.x = MathUtils.random(0, Gdx.graphics.getWidth()/2 - 64);
word.y = Gdx.graphics.getHeight();
words.add(word);
}
public String getWordString(){
return wordString;
}
}
你的意思是对象BitmapFont?请张贴一些代码,以便我们可以看到你的BitmapFont是什么。 – IronMonkey
对不起,我添加了一些我认为可以帮助解决的代码。 – GeeSplit
您可以从BitmapFont中创建多个BitmapFontCaches并绘制它们。它们重量更轻,不需要处理。 – Tenfour04