Sign in to follow this  

Alpha value isn't affecting transparency

This topic is 2545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I'm just now dipping my toes into the XNA pool, so hopefully my questions aren't too ridiculous. Anyway, I'm trying to fade in a splash image, but the alpha value doesn't seem to have any effect whatsoever on the appearance of the image. Here's what I'm doing in the draw method:

GraphicsDevice.Clear(Color.Black);
// TODO: Add your drawing code here
spriteBatch.Begin();
spriteBatch.Draw(test, testR, new Color(255, 255, 255, 0));
spriteBatch.End();
base.Draw(gameTime);

(I know I'll need a variable for alpha if I want to fade, but I'm just using a constant right now for testing)
The image displays to the screen and everything like it should, and its tone even changes when I adjust the RGB values, but NOTHING happens when I change that fourth number. I'm using XNA 4.0. Any ideas on what I might be doing wrong? Thanks in advance for any feedback.

Share this post


Link to post
Share on other sites
In XNA 4.0 they changed the way the default SpriteBatch does alpha blending. It now uses Premultiplied alpha, which means you also have to change the RGB values to get "fade" effects.

More explanation here: http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx

Share this post


Link to post
Share on other sites

This topic is 2545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this