Jump to content
  • Advertisement
Sign in to follow this  

HUD transparency

This topic is 2951 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

Hi guys I was wondering if there was a way of making a transparent HUD for an XNA game? I was thinking it could have something to do with the actual image itself, but I am not sure how to go about it. Any help on the matter would be appreciated!

Share this post

Link to post
Share on other sites
Well, what you need to do is create a texture with colours of set Alpha transparency.

Texture2D CopyTransTexture(GraphicsDevice device, Texture2D Texture, float Alpha)
//2 Color[]
//This one is kept empty
Color[] HolderColors = new Color[Texture.Width * Texture.Height];
//We use this to store the colors of out Texture
Color[] colorData = new Color[Texture.Width * Texture.Height];

//Get the Color Data from our Texture

//Assign these to out holder Array
for (int i = 0; i < colorData.Length; i++)
HolderColors = new Color(colorData, Alpha);

//Create a new Texture from the Colors with set alpha
Texture2D holder = new Texture2D(device, Texture.Width, Texture.Height, 1, TextureUsage.None, SurfaceFormat.Color);
//And return it
return holder;

This simple functions takes a texture and recreates it with a set Alpha Value

N.B I just rustled this up so i'm not sure if it will work, theoretically it should. Any problems plz reply xD

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!