Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Help needed with drawing sprite?  (Read 1598 times)

0 Members and 1 Guest are viewing this topic.

Austin J

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Help needed with drawing sprite?
« 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.



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?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Help needed with drawing sprite?
« Reply #1 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).

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: Help needed with drawing sprite?
« Reply #2 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
Failing to succeed does not mean failing to progress!

 

anything