[LibGDX] Cinematic text rendering

So I’ve noticed that a lot of games these days tend to render their text one character at a time (usually with typing sound effects playing), to gradually show it to the user. I’m trying to find the best way to do this in LibGDX but I just can’t produce the right time keeping mechanism.

So far I have:


public void renderCinematicString(String string, BitmapFont font, Vector2 pos, Color color){

	for(int i = 0; i < string.length(); i++){
        //TODO timing mechanism to wait x amount of milliseconds
		font.draw(spriteBatch, string.charAt(i)+"", pos.x + (i * spacing * font.getBounds(" ").width), pos.y);
	}
		
}

Any suggestions? Please tell me if anything’s unclear.

Thanks :slight_smile: