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

2013/6/12

showing text

bahrie bahrie

2013/6/12

#
how to show String on the greenfoot.,.???
Zamoht Zamoht

2013/6/12

#
GreenfootImage image = new GreenfootImage(100, 30); image.drawString("Your text"); setImage(image); Put this in the actor you want to display the text. Also take a look at the API .
Gevater_Tod4711 Gevater_Tod4711

2013/6/12

#
I think using this constructor of the class GreenfootImage would be better that drawing the String. If you use this constructor you can do it like this:
GreenfootImage img = new GreenfootImage("The text (String) you want to print.", 35, Color.black, new Color(0, 0, 0, 0));
//That will make a GreenfootImage with your string with black letters on a transparent ground with a font size of 35;
setImage(img); //you need to set the image of your actor to the image you created to see it;
Gevater_Tod4711 Gevater_Tod4711

2013/6/12

#
Forgot to say: You need to import java.awt.Color to use the class Color.
You need to login to post a reply.