SFML community forums

Help => Graphics => Topic started by: Sander on March 17, 2009, 04:57:00 pm

Title: Change opacity for fade out effect
Post by: Sander on March 17, 2009, 04:57:00 pm
Hello,

I'm new to SFML and I've been playing around with it for a bit. I'm currently trying to create a pretty standard fade out effect; just fade to black. I've tried changing the opacity using Sprite.Color, but this isn't working. Here's my code;

Code: [Select]
Image img = new Image(640, 480, new Color(0,0,0, 0));

Sprite spr = new Sprite(img);
spr.Color = new Color(0, 0, 0, 100);

Window.Instance.Draw(spr);
Window.Instance.Display();


When drawn, the alpha isn't changed to 100; it's still 0.

So, what's the correct way to do what I'm trying? Thanks.

Edit: Oh, this is C# btw.
Title: Change opacity for fade out effect
Post by: Laurent on March 17, 2009, 05:27:35 pm
Your source image has an alpha value of 0. Whatever your sprite's color is, it will still be 0 (both are multiplicated to get the final component).

You should leave the alpha as 255 in the image, and only play with the sprite's color.
Title: Change opacity for fade out effect
Post by: Sander on March 18, 2009, 10:20:53 am
Awesome, got it. Thanks!