This site requires JavaScript, please enable it in your browser!
Greenfoot back
sengst
sengst wrote ...

2014/8/4

How to add text

sengst sengst

2014/8/4

#
Hello. I was wondering if someone knows how to add text into a world? Thanks.
danpost danpost

2014/8/4

#
There are several ways: (1) use 'getBackground().drawString("xxxxxx", 20, 30);'; you may have to change the drawing color of the background image before drawing the string; also, you may want to alter the drawing Font (2) create a text GreenfootImage using the constructor that requires a string and then use 'getBackground().drawImage(textImage, 20, 10);' to add it to the background image (3) create a text GreenfootImage as in (2) above and set it to be the image of an actor and add the actor into the world The easiest to remove and the simplest to use is (3). If you have a flat background color (not patterned or designed or pictured), then it would not be too difficult to remove when using (1) or (2) (re-drawing the text in the background color), unless it is the only change to the background image, where you can restore the background image itself.
You need to login to post a reply.