What I try to make is:
- Draw a BitmapFont on the top of the screen and let it go down to the bottom, where it gets deleted.
- While that BitmapFont is still making its way down, draw another BitmapFont with different text.
- Repeat 1 and 2.
Is this achievable with one BitmapFont or do I have to make multiple BitmapFonts in order for this to work?
EDIT:
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()
is the text I want to show, which changes with every loop. What it does now is change the text of the newly drawn word that spawns at the top, but also the previous one.
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;
}
}