Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a problem through out my current code where certain Texture2D's are not drawing correctly over each other.

For example, at the start I have sprite font being drawn over a background image and half the text is not shown when I add the image.

        _sb.Draw(_background, new Rectangle(0, 0, 800, 480), Color.White);
        if (isPaused)
            _sb.DrawString(_bigFont, "Resume", new Vector2(295, 200), Color.Black);
        else
        _sb.DrawString(_bigFont, "Start", new Vector2(315, 200), Color.Black);

The text then seems to appear if I change the value of other text on the screen.

Is there something I am missing here?

Thanks.

share|improve this question
    
How are you initializing the SpriteBatch? –  John McDonald Feb 24 '12 at 23:35
    
spriteBatch = new SpriteBatch(GraphicsDevice); –  boburob Feb 24 '12 at 23:38
    
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); –  boburob Feb 24 '12 at 23:38
    
Can we have a picture? –  ClassicThunder Feb 25 '12 at 0:03
    
tinypic.com/r/28vef77/5 When I update the something else on the screen the text appears. –  boburob Feb 25 '12 at 0:16
add comment

1 Answer

up vote 2 down vote accepted

Unless you are actually playing with the Depth, you should be using SpriteSortMode.Deferred. MSDN Doc Here

If you are drawing everything at Depth 0, I'm pretty sure that XNA will pick a draw order for you. There are others discussing a similar issue here: http://forums.create.msdn.com/forums/p/72055/439545.aspx.

In 3D, this is usually called Z-fighting.

share|improve this answer
    
Perfect, thank you very much. –  boburob Feb 25 '12 at 0:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.