I use the following code in my update loop
if (!flip){
if (alpha > 0){
alpha -= Ticks;
}
else{
Ticks = 0;
flip = true;
}
}
else{
if (alpha < 255){
alpha += Ticks;
}
else{
if (transition == 1){
screenManager->ChangeState(new Menu(render));
}
Ticks = 0;
alpha = 255;
transition = 1;
flip = false;
}
}
and here is my draw code
if (transition == 0){
background->Draw(&screen);
}
else{
background2->Draw(&screen);
}
SDL_SetRenderDrawColor(render, 0, 0, 0, alpha);
SDL_RenderFillRect(render, &dstrect);
Why does it flicker when running the fade in animation and if possible a solution would be nice.
Fixed the problem and for anyone that wants to know it was due to the fact that the alpha went bellow 0 and above 255 because i was adding a double.