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

2013/2/22

Characters text on screen

VictorFATEC VictorFATEC

2013/2/22

#
Hi guys, I'm trying to make my characters shows some text messages. I can make them show the messages but I can't remove the messages. I'm using the method getWorld().getBackground().drawString ..... so the dialog stays on the screen forever. How can i remove the dialogs?
Gevater_Tod4711 Gevater_Tod4711

2013/2/22

#
You have to overdraw them. Or if your background is an image you have to load the file new and change the image. Another way would be to use objects for drawing the strings so that you can remove the objects.
VictorFATEC VictorFATEC

2013/2/22

#
If I use the method again it will overwrite the other dialog. The bg is an image, are you saying to reload the bg image?
danpost danpost

2013/2/22

#
To remove the text: change the drawing color for the background to the background color and re-draw the same string at the same location.
VictorFATEC VictorFATEC

2013/2/22

#
Thns @danpost !!! It works But if I use a bg image with multiple color I'll still having this problem
danpost danpost

2013/2/22

#
If your background is multi-colored, then you should probably save the background image in an instance GreenfootImage field before writing any text on it.
// add this instance object field to the class
private GreenfootImage bgBaseImage;
// after the base background image is set, in the world constructor
bgBaseImage = new GreenfootImage(getBackground());
// then you can write on background

// to remove the text
setBackground(new GreenfootImage(bgBaseImage));
You need to login to post a reply.