Reputation: 830
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.
Upvotes: 2
Views: 321
Reputation:
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
Upvotes: 0
Reputation: 5762
if you are using spritebatch is easy:
float alpha = desired_alpha;
spritebatch.Draw(texture, pos, source, Color.White * alpha);
Upvotes: 3