开发者

Drawing textures with variable transparency

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 al开发者_StackOverflowpha 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.


if you are using spritebatch is easy:

 float alpha = desired_alpha;

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜