Hello, I'm new to XNA as well as DirectX and am experiencing some weird side effects when drawing a sprite that I can't account for. I have a 3D ship that I can fly around using the Xbox360 controller (completed the XNA tutorials 1-3) and decided to see if I could implement pausing.

Well, i got everything working how I want it and even made a 2d sprite that loads a texture asset and draws it to the screen when the player pauses (just a blue rectangle with the word "Paused..." written on it). That works great too, except by drawing the sprite to the screen my 3d model suddenly becomes semi-transparent! Even when the sprite is no longer being drawn the model remains semi-transparent until I restart the game.

I am developing in XNA Game Studio Express and deploying onto my Xbox360.

I am confused by this side-effect of drawing the sprite. The 3d model references a .tga for it's texture but it is completely separate from my .bmp texture (which has been added through the content pipeline).

Here's the code that causes the effect (by commenting it out I no longer see the Pause sprite but also no longer get semi-transparency on the model):



new Rectangle(graphics.GraphicsDevice.Viewport.Width/2 - pauseTexture.Width/2,

graphics.GraphicsDevice.Viewport.Height/2 - pauseTexture.Height/2,





At first I didn't use a SpriteBlendMode but thought maybe by explicitly using SpriteBlendMode.None I would avoid any possible transparency confusion, but it has no effect.

Re: XNA Game Studio Express XNA sprite behavior -- weird side effect

Eli Tayrien - MSFT

You might find these links helpful:

After drawing using SpriteBatch, why do my 3D objects draw incorrectly

By default, SpriteBatch.Begin does not save your current render state, and will change certain render state properties that may make 3D objects render incorrectly. You can choose to either reset the render state yourself after the call to SpriteBatch.End, or call SpriteBatch.Begin and pass in SaveStateMode.SaveState, which will restore the render state after sprites are drawn.

Re: XNA Game Studio Express XNA sprite behavior -- weird side effect



Are there any performance considerations to which option to choose I certainly find it easier to set the SaveStateMode than to manually adjust my device, but I wonder if it would ever be prudent to manually change just the device settings necessary

Re: XNA Game Studio Express XNA sprite behavior -- weird side effect


I ended up using a different SpriteBatch.Begin overload as follows:


and now it works as I expect!

Thanks Eli!

Re: XNA Game Studio Express XNA sprite behavior -- weird side effect


Sorry Eli,

I posted the last post before reading Shawn's blog you referenced. Never mind. ;-)