Is there any specific way to fade a sprite or an image in SFML? I've been trying to do it for some time now and I can never get it to work.
Here's what I'm trying to:
sf::Image Overworld;
if(!Overworld.LoadFromFile("overworld.png"))
......
int alpha = 0;
sf::Sprite OverworldSprite(Overworld);
OverworldSprite.SetColor(sf::Color(255, 255, 255, alpha));
float filterDelay = 0.02;
sf::Clock clockFilter;
if((alpha < 100) && (clockFilter.GetElapsedTime() > filterDelay))
{
alpha += 1;
OverworldSprite.SetColor(sf::Color(255, 255, 255, alpha));
clockFilter.Reset();
}
The above mentioned code just nets me a black screen. Thus, the alpha variable isn't being changed/the change is overridden by something. What am I doing wrong? Also, if there is a better way just let me know.