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

2012/10/1

Need help by drawing images

Gevater_Tod4711 Gevater_Tod4711

2012/10/1

#
Hi all, I want to create a better texture for my worms szenario and I need to know if it's possible to overdraw and image with a transperency, so that the image is transperent at this part. And I also need to know where I can get a transperent color. I haven't found such a color in the api java.awt.Color;
danpost danpost

2012/10/1

#
getIimage().clear() will make any actor object's image transparent (if that is what you mean); and, new Color(0, 0, 0, 0) is transparent (although, the first three parameters can be anything in the 0 to 255 range). If you are just trying to 'hide' the object, you can use getImage().setTransparency(0) and then 'show' the object later with getImage().setTransparency(255). Be aware that the act method will still run while the object is in 'hide' mode; but you can get around that by using 'if (getImage().getTransparency() != 0)' around the code within the act method.
danpost danpost

2012/10/1

#
If you are hoping to change a part of an image to transparent, then check out the code of my Spot-lights Demo
Gevater_Tod4711 Gevater_Tod4711

2012/10/1

#
@danpost Thank you. Your Spot-lights Demo realy helped me.
Gevater_Tod4711 Gevater_Tod4711

2012/10/4

#
Another question: If I use setColorAt(x, y, new Color(0, 0, 0, 0)) the Image is transparent at the coordinates. But if I use setColor(new Color(0, 0, 0, 0)); and fillOval(x, y, deltaX, deltaY); there is no change at the image. Am I doing something wrong or should the Image act like this?
SPower SPower

2012/10/4

#
That's normal.
Gevater_Tod4711 Gevater_Tod4711

2012/10/4

#
@SPower Ok thank you. I don't think this is very usefull but if its normal I'll try to use other ways.
You need to login to post a reply.