I'm going to make a briefing state that telling story with some words running (like typewritter) in screen. Some kind like this
September 28,
The monster has overtaken the city. Somehow, I'm still alive.
NOTE: you'll notice I quote an example from RE3

However, it seems that break line \n doesnt work on g.drawString() method. The full length text went out the screen. My current approach is create N number of string in array for every number of line.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| public void update(long delta){ d += delta; if (d > 50 && !finish){ if (!halfFinish){ sb1.append(TEXT[level][0].charAt(textCount)); textCount++; if (textCount == TEXT[level][0].length()){ textCount = 0; halfFinish = true; } d = 0; }else{ sb2.append(TEXT[level][1].charAt(textCount)); textCount++; if (textCount == TEXT[level][1].length()) finish = true; d = 0; } } }
public void draw(Graphics2D g){ g.setColor(Color.black); g.drawString(sb1.toString(),50,100); g.drawString(sb2.toString(),50,200); } |
This is not good and I want to know your better approach for this problem. Thanks
