XNA Creators Club Online
Page 1 of 1 (6 items)
Sort Posts: Previous Next

Fade Effect

Last post 10/20/2009 8:00 PM by George Clingerman. 5 replies.
  • 10/20/2009 7:33 PM

    Fade Effect

    I am using the following code to fade in a texture:

     

    //Add Elapsed Time.

     

     

     

     

     

    Game1.IntroTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

     

     

    if (Game1.FadeEffect == 1)

     

    {

     

    //Test Current Alpha Value.

     

     

     

     

     

     

    if (Game1.FadeValue < 255)

     

    {

     

    Game1.FadeValue = Game1.FadeValue + (Game1.IntroTime * Game1.FadeSpeed);

     

    }

     

    else

     

     

     

     

     

    {

     

    Game1.FadeValue = 255;

     

     

    Game1.FadeEffect = 2;

     

    }

    }

     

     

     


    I am having problems trying to reverse this. What I want is the texture to fade in and when the alpha value has reached 250 I then want it to fade back out.

    Can anyone help?
    Speed - Now Available For Download
  • 10/20/2009 7:38 PM In reply to

    Re: Fade Effect

    Answer
    Reply Quote
  • 10/20/2009 7:41 PM In reply to

    Re: Fade Effect

    Why not have a color variable such as fade_color, set it to 255, 255, 255, 255

    Then have on each update minus/add a 1 or whatever suits you to the alpha. You can pass the color through the update.
    Such as if you had a alpha class:

    alpha_class.Update(gameTime, clientBounds, fade_color);
    teK-Junkies: 'where one man's junk becomes another man's tek'
  • 10/20/2009 7:43 PM In reply to

    Re: Fade Effect

    Please use the code snippet button to post code (it's the fourth from the right if you have the rich text editor). It will make your code much cleaner and easier to read.
  • 10/20/2009 7:59 PM In reply to

    Re: Fade Effect

    This is exactly what I wanted. I actually used this tutorial before but could not find it this time. Thanks a lot.
    Speed - Now Available For Download
  • 10/20/2009 8:00 PM In reply to

    Re: Fade Effect

    No problem, glad you liked my tutorials :)  I'll have to figure out why they were hard to find, maybe I need to improve my sites keywords.
Page 1 of 1 (6 items) Previous Next