0

I'm trying to have my Splash Screen fade into black. I realized it fades into whatever color the screen is cleared with in the default line GraphicsDevice.Clear(Color.White); in the default update method. When I make it white, my image fades into white, which makes sense. So I changed it from White to Black but my image no longer fades at all or doesn't look like it.

public void SplashUpdate(GameTime theTime)
        {
            gameTime = theTime;

            if ( theTime.TotalGameTime.Seconds > 1.4 )
            {
                Draw.blender.A --;
                if (Draw.blender.A == 0)
                {
                    game1.currentState = PixeBlastGame.Game1.GameState.gameSplash;
                    MediaPlayer.Play(Game1.sMenu);
                }
            }
        }

blender is the color that is applied to my Texture for the splash screen and is defined like so, public static Color blender = new Color(255, 255, 255);

freemann098
  • 284
  • 1
  • 7
  • 22

1 Answers1

1

Xna 4.0 uses premultiplied alpha so your code is not right.... you should multiply the color by the alpha... but i'd do something similar to this:

 float fadeDuration = 1;
 float fadeStart = 1.4f;
 float timeElapsed = 0;
 Color StartColor = Color.White;
 Color EndColor = Color.Transparent;

 void Update(GameTime time)
 {
     float secs = (float) time.ElapsedTime.TotalSeconds;

     timeElapsed += secs;
     if (timeElapsed>fadeStart)
     {
          // Value in 0..1 range
          var alpha =(timeElapsed - fadeStart)/fadeDuration;  
          Draw.Blender = Color.White * (1 - alpha);
          // or Draw.Blender = Color.Lerp(StartColor, EndColor, alpha);

          if (timeElapsed>fadeDuration + fadeStart)
          {
                Draw.Blender = EndColor;
                // Change state
          }
     }
 }
Blau
  • 5,742
  • 1
  • 18
  • 27
  • I tried this and it made sense to me but now it just sits at the splash screen doing nothing. – freemann098 Apr 21 '13 at 21:32
  • are you sure that you are modifying Draw.Blender color and that you are using it as parameter in the spriteBatch.Draw method? – Blau Apr 22 '13 at 00:21