开发者

XNA Alpha Blending part of a texture in Game Studio 4.0

Hi I'm trying to follow an answer about making part of a texture transparent when using Alpha Blending from this question The only problem is that this only works in XNA 3.1 and I'm working in XNA 4.0 so stuff like RenderState doesn't exist in the same context, and I have no idea where to find the GfxComponent class开发者_StackOverflow library.

I still want to do the same thing as in the example question, a circular area radiating from the mouse position that makes the covering texture transparent when the mouse is hovering over it.


3.5

GraphicsDevice.RenderState.AlphaBlendEnable = true;

4.0

GraphicsDevice.BlendState = BlendState.AlphaBlend;

See Shawn Hargreaves post for more info: http://blogs.msdn.com/b/shawnhar/archive/2010/06/18/spritebatch-and-renderstates-in-xna-game-studio-4-0.aspx

EDIT: In the post you can see Shawn using BlendState. You create a new instance of this, set it up however you like, and pass this to the graphics device. Like so:

BlendState bs = new BlendState();
bs.AlphaSourceBlend = Blend.One;
bs.AlphaDestinationBlend = Blend.Zero;
bs.ColorSourceBlend = Blend.Zero;
bs.ColorDestinationBlend = Blend.One;
bs.AlphaBlendFunction = BlendFunction.Add;
graphicsDevice.BlendState = bs;

That clearer?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜