SFML community forums

Help => Graphics => Topic started by: dsdevil on February 14, 2011, 09:21:45 pm

Title: Transparecy and layers
Post by: dsdevil 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?
Title: Transparecy and layers
Post by: Laurent 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 ;)
Title: Transparecy and layers
Post by: dsdevil 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?
Title: Transparecy and layers
Post by: Groogy 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.
Title: Transparecy and layers
Post by: dsdevil on February 15, 2011, 08:54:00 pm
I did it in my image editor. Works awsomly. Thanx a lot guys.