SFML community forums
Help => Graphics => Topic started by: dusan on May 27, 2012, 08:31:56 pm
-
Hello,
I am still newbe in SFML since I started like a day ago :D .
So far I created TicTacToe game you can see it here (http://en.sfml-dev.org/forums/index.php?topic=8059.0).
Now I moved on Pong game and I have a problem.
In this game I have ball picture it is simple ball with white background. But my window background is other picture (green color) that I found on google. So when I draw ball on that background I saw rectangle - the whole image that ball is.
I just want to make ball visible not background
Is there any way of achieving this ?
-
If your ball image is there with a white rectangle around it, sounds like you need the area around the ball to be alpha level 0 (transparent). You can do this using an image editor like Gimp.
-
3 possibilities :
- edit your image so that it has a transparent background, like Jove said
- take an image that already has a transparent background
- use sf::Image::createMaskFromColor(sf::Color::White)
The latest one will tell SFML that the white color (background of your ball image) should not be displayed.
-
Ty for replays.
sf::Image::createMaskFromColor(sf::Color::White) worked great!
And editing image is also easier and maybe better solution than createMaskFromColor.
Ty anyway it helped a lot!