1
Graphics / [SOLVED]Fading a sprite/image in or out
« on: June 06, 2010, 09:52:43 pm »Quote from: "Ashenwraith"
Here I just coded up an example, maybe someone can post it on the wiki or something. I noticed this has been asked three of four times on the forum.
In the future you should post the loop when people ask you because that's what makes it work. If you don't know what a loop is just search online.Code: [Select]#include <SFML/Graphics.hpp>
//***********************************
int main()
{
sf::Sprite sprt;
sf::Image img;
img.LoadFromFile("image.png");
sprt.SetImage(img);
sf::RenderWindow App(sf::VideoMode(1600,800,32),"SFML Alpha Demo");
App.SetFramerateLimit(60);
App.UseVerticalSync(false);
int a=255;
while(App.IsOpened())
{
if(a<0){a=255;}
sprt.SetColor(sf::Color(255,255,255,a));
a--;
App.Clear(sf::Color::Green);
App.Draw(sprt);
App.Display();
}
return EXIT_SUCCESS;
}
Thanks for helping out.