Jump to content
  • Advertisement
Sign in to follow this  
tstrimp

XNA SpriteBatch.DrawString Breaks zOrder

This topic is 2350 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Just getting into XNA development for a phone game I'm toying around with and I'm running into a strange (to me anyway) issue. Everything has been working fine, up until I started trying to render text on the screen along with the primitives. See the screenshots below. When I'm not rendering the text, the ball is correctly displayed in front of the "paddle". Once I draw some simple text in the corner, you can see how the ball is now rendered behind the back paddle regardless of the objects z position. Any one know what I'm doing wrong here?

2011-12-15_2325.png


2011-12-15_2325.png


Here is the order of how I'm currently rendering the scene



_spriteBatch.Begin();
_gameObjects.Draw();
_spriteBatch.DrawString(_sergio, _cpuLives.ToString(),
new Vector2(SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Width, 10),
Color.White, MathHelper.PiOver2,
new Vector2(0.0f, 0.0f), 1.0f, SpriteEffects.None, 1.0f);
_spriteBatch.End();

Share this post


Link to post
Share on other sites
Advertisement
Quick update, removing the DrawString has the same behavior as long as I still have the SpriteBatch.Begin and End calls.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!