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

Author Topic: How do I layer a sprite onto a bg?  (Read 2433 times)

0 Members and 1 Guest are viewing this topic.

pabloist

  • Newbie
  • *
  • Posts: 26
    • View Profile
How do I layer a sprite onto a bg?
« on: September 15, 2010, 06:49:20 am »
I have a colored bg that I'm trying to place a sprite on top of; but the sprite I'm trying to put on top has whitespace. Is there a way for me to get rid of it? I tried using Sprite.SetBlendMode(sf::Blend::Mode::Multiply) but that causes the rest of the character to change color along with the bg.

If there's no code solution, is there a way for me to just get rid of the surrounding whitespace?

(sorry if any of this seems stupid, I'm playing around with the tutorial stuff right now. I also only have MS Paint :P)

PeterWelzien

  • Newbie
  • *
  • Posts: 38
    • View Profile
How do I layer a sprite onto a bg?
« Reply #1 on: September 15, 2010, 07:41:47 am »
I think the function you need is:
Code: [Select]
void sf::Image::CreateMaskFromColor(Color ColorKey, Uint8 Alpha = 0)
/Peter Welzien

pabloist

  • Newbie
  • *
  • Posts: 26
    • View Profile
How do I layer a sprite onto a bg?
« Reply #2 on: September 16, 2010, 02:13:41 am »
Thank you, that's exactly what I was looking for!

renton_django

  • Newbie
  • *
  • Posts: 8
    • View Profile
How do I layer a sprite onto a bg?
« Reply #3 on: October 06, 2010, 06:57:25 pm »
Performance wise, how does this compare with using transparent pngs?

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
How do I layer a sprite onto a bg?
« Reply #4 on: October 06, 2010, 07:02:19 pm »
Quote from: "renton_django"
Performance wise, how does this compare with using transparent pngs?

I recommend to use sf::Clock to test it for yourself

 

anything