0
\$\begingroup\$

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.

\$\endgroup\$
5
  • \$\begingroup\$ How are you initializing the SpriteBatch? \$\endgroup\$ Feb 24, 2012 at 23:35
  • \$\begingroup\$ spriteBatch = new SpriteBatch(GraphicsDevice); \$\endgroup\$
    – boburob
    Feb 24, 2012 at 23:38
  • \$\begingroup\$ spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); \$\endgroup\$
    – boburob
    Feb 24, 2012 at 23:38
  • \$\begingroup\$ Can we have a picture? \$\endgroup\$ Feb 25, 2012 at 0:03
  • \$\begingroup\$ tinypic.com/r/28vef77/5 When I update the something else on the screen the text appears. \$\endgroup\$
    – boburob
    Feb 25, 2012 at 0:16

1 Answer 1

2
\$\begingroup\$

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.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .