-4

Is there any way to make a some text appear as a paragraph, since at the moment i use,

private String howtoplay = "[Insert How To Play THe Game Instructions Here]";

When i use strings the text just goes off my game screen which is 800 pixels by 600 pixels.

How do i make it so it doesn't go out of the screen and just either just a block of text, or that when the word reaches the end of the game screen, it will start on a new line.

I have only used strings and so i have been used t using them to create small amounts of text like the title and small commands instructing what button to click.

So in short, is there any way to create a block of text without creating like another class, or just creating a bunch of strings?

EDIT: So it turns out that i cannot create a new line break, due to the fact i have a drawString

g.drawString(title, ((Sea_InvadersDisplay.WIDTH/2)-(titleWidth/2))-2,      (Sea_InvadersDisplay.HEIGHT/2)-123);

and i have found the solution here: Problems with newline in Graphics2D.drawString So in other words i have found the solution to my problem.

Community
  • 1
  • 1
Gassy
  • 11
  • 1
  • 3

2 Answers2

0

use can \n to break to the next line and you can use. everytime you need to move to a new line or new row u just pass \n into your string

Lordwiz
  • 13
  • 1
  • 3
0

Try to use html code.... new line in html code is represented by <br/> tag... so you will have something like this:

<html>
    <p>[Insert How To Play THe Game Instructions Here]</p>
</html>
Dali Freire
  • 129
  • 1
  • 13