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

Author Topic: Change opacity for fade out effect  (Read 4712 times)

0 Members and 1 Guest are viewing this topic.

Sander

  • Newbie
  • *
  • Posts: 2
    • View Profile
Change opacity for fade out effect
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Change opacity for fade out effect
« Reply #1 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.
Laurent Gomila - SFML developer

Sander

  • Newbie
  • *
  • Posts: 2
    • View Profile
Change opacity for fade out effect
« Reply #2 on: March 18, 2009, 10:20:53 am »
Awesome, got it. Thanks!

 

anything