SFML community forums

Help => Graphics => Topic started by: Austin J on September 26, 2013, 07:04:26 am

Title: Help needed with drawing sprite?
Post by: Austin J on September 26, 2013, 07:04:26 am
It involves a white box, and no, believe it or not it's not because the sprite loses a reference to a texture  ;)

In SDL, when you're drawing tanks, spaceships, monsters, whatever, you had to write some code to get rid of that annoying background.

When I draw a sprite, it has that annoying background, a good example would be my custom mouse cursor.

(http://i40.tinypic.com/w0cox.png)

I haven't been able to find anything regarding SFML on how to keep this from happening. This is the second game I'm working on. Last game was very simple, just an altered version of Battleship, so I could just make the background color for a sprite texture match the board. I can't do that now though.

Can someone be a pal and tell me how to handle this?
Title: Re: Help needed with drawing sprite?
Post by: Ixrec on September 26, 2013, 07:44:09 am
You just make the actual image have a transparent background instead of a white one.  No code should be involved.

If you don't know how to do this, that's probably because MS Paint is terrible and cannot handle transparency.  There are plenty of superior free image editors like Paint.net and GIMP which can very easily deal with transparency (and a million other things).
Title: Re: Help needed with drawing sprite?
Post by: Geheim on September 26, 2013, 12:46:25 pm
You could also make an sf::Image and call the function createMaskFromColor and set white as your mask color: http://www.sfml-dev.org/documentation/2.0/classsf_1_1Image.php