Hi,
I'm trying to make a game, so when the NPC talks to the player, I want the text to type it self
So it would be like:
H
He
Hey
Hey t
Hey th
Hey the
Hey ther
Hey there
Instead of just
Hey there.
I've attempted to do this using a for loop, but I end up with a messy text.
public void render(Graphics g){
g.drawImage(background , 0, 0, null);
g.drawImage(oak, (Game.WIDTH / 2) - (oak.getWidth() / 2) , (Game.HEIGHT / 2) - (oak.getHeight() / 2) - 55, null);
g.drawImage(messageText, 5, (Game.HEIGHT - messageText.getHeight()) - 25, null);
//The above is just some other stuff.
String[] oakSpeech = new String[10];
oakSpeech[0] = "Hello there";
for(int i = 0; i <= oakSpeech[0].length; i++){
drawStringWithShadow(oakSpeech[0].substring(i));
}
}
The for loop doesn't work, it creates a jumbled up text which seems really messy. Anyone have any idea how to do this?
Thanks,
Neil