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

Author Topic: Transparecy and layers  (Read 2265 times)

0 Members and 2 Guests are viewing this topic.

dsdevil

  • Newbie
  • *
  • Posts: 11
    • View Profile
Transparecy and layers
« on: February 14, 2011, 09:21:45 pm »
Hello guys!
Yesterday i made my first little demo with sfml i  was incredebly happy!
Now i have some problems.
1. How to make some color transparent?
2. How can i make so that some sprites are behind and in front of other. For example, if i add bacground, i would like it to be behind all other objects. Can i do that?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Transparecy and layers
« Reply #1 on: February 14, 2011, 11:07:45 pm »
Quote
1. How to make some color transparent?

The alpha (fourth) component of colors is the transparency.

Quote
2. How can i make so that some sprites are behind and in front of other. For example, if i add bacground, i would like it to be behind all other objects. Can i do that?

Draw first your background, and then the rest. Simple ;)
Laurent Gomila - SFML developer

dsdevil

  • Newbie
  • *
  • Posts: 11
    • View Profile
Transparecy and layers
« Reply #2 on: February 15, 2011, 08:11:48 pm »
Quote from: "Laurent"
Quote
1. How to make some color transparent?

The alpha (fourth) component of colors is the transparency.

Quote
2. How can i make so that some sprites are behind and in front of other. For example, if i add bacground, i would like it to be behind all other objects. Can i do that?

Draw first your background, and then the rest. Simple ;)


Wow, the second i really simple :)
But with this alpha thing in first, do i have to do it in my picture editor or in code somehow?

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Transparecy and layers
« Reply #3 on: February 15, 2011, 08:40:36 pm »
You can do it either way or even both if you want too. Check out Sprite::SetColor function.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

dsdevil

  • Newbie
  • *
  • Posts: 11
    • View Profile
Transparecy and layers
« Reply #4 on: February 15, 2011, 08:54:00 pm »
I did it in my image editor. Works awsomly. Thanx a lot guys.