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

2024/5/21

Make Actor Background Transparent

CoolKid CoolKid

2024/5/21

#
I'm Using Greenfoot for school to make a chess game but when I go to create the chess pieces as actors the background is always a color and I can't make it transparent. if you look at a normal chess board you can see the piece and then the board space's color that the piece is on. I want mine to look like that any Advice would be constructive.
danpost danpost

2024/5/23

#
Options include (but may not be limited to):
  • find an image set that has transparent backgrounds
  • use image editing tools to remove the background from the image set you currently have
AriesNinja AriesNinja

2024/5/26

#
You can also do something like this to convert white to transparent:
            GreenfootImage img = getImage();
            for(int i=0; i<img.getWidth(); i++)
            {
                for(int j=0; j<img.getHeight(); j++)
                {
                    Color col=img.getColorAt(i,j);
                    if (col.getRed() + col.getBlue() + col.getGreen() < 15) {
                        img.setColorAt(i,j,new Color(0,0,0,0));
                    }
                }
                setImage(img);
            }
You need to login to post a reply.