2
votes

I am a moderately experienced C# developer, but I'm new to XNA and graphics in general. I'm making a 2D game and I'm trying to draw a texture that partially transparent. The desired transparency value is stored in a float variable. The only solution I've found is to directly edit the alpha values in the texture each frame, but that seems inefficient. I've tried using alpha blending, but I haven't been able to figure out how to use my own transparency value. Is there a better way to do it?

Edit: Added more information.

2
Can you post the code you're trying to use?thedaian
None of the code that I've tried has done what I want, so I don't really have any code yet.GregoryComer

2 Answers

3
votes

if you are using spritebatch is easy:

 float alpha = desired_alpha;

 spritebatch.Draw(texture, pos, source, Color.White * alpha);
0
votes

You could try using this Color constructor to pass in your alpha value:

http://msdn.microsoft.com/en-us/library/dd231957(v=xnagamestudio.31).aspx