I don't know how to do this strangely enough. I have a name/story generator that I am working on, but I need to have the text wrap. Anybody know how to do this? here is my current code (minus the generation algorithms):
This is all carried out fine, but the text goes off the screen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | String Homeland = newName( "" ); String Hero = newName( "" ); String Family = newName( "" ); String Season = newName( "" ); String LegendarySword = newName( "" ); String LegendaryBeast = newName( "" ); String txt = "In the land of " + Homeland + ", there was a Hero. His name, " + Hero + ", was that of the " + Family + " Clan. They were known for defeating the great " + LegendaryBeast + " who had threatened the entire land. " + Hero + " recieved the ancient blade " + LegendarySword + " when he turned eighteen. This was a time of merryment and celebration, but it was not so. That evening, the great beast, " + LegendaryBeast + ", rose from the forest. It had returned, and sought vengence on the family who had smited it so long ago." ; GreenfootImage textImage = new GreenfootImage(txt, 24 , new Color( 208 , 191 , 146 ), new Color( 0 , 0 , 0 , 0 )); GreenfootImage image = new GreenfootImage(textImage.getWidth()+ 12 , 36 ); image.setColor( new Color( 0 , 0 , 0 )); image.fill(); image.setColor( new Color( 158 , 141 , 96 )); image.fillRect( 3 , 3 , image.getWidth()- 6 , 30 ); image.drawImage(textImage, 6 , 6 ); this .setImage(image); |