1
\$\begingroup\$

What is an example of efficient sprite batching in XNA?

I don't know when (if ever) I would do something like this:

spriteBatch.Begin()
DrawSprite1();
spriteBatch.End();

spriteBatch.Begin();
DrawSprite2();
spriteBatch.End();

Is there any time within a draw method that I would separate drawing calls like this?

Thanks!

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

Effective usage is only using one single spirebatch for the game. Simply call Begin() at the start of the frame and End() at the end.
However, there are some usage for multible batches. You can set them up only draw the content when you call End(). With this you could use one spritebatch for the game and one for the GUI with having problem with game elements overlapping GUI elements. http://blogs.msdn.com/b/shawnhar/archive/2006/12/14/spritebatch-sorting-part-2.aspx

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Another use for multiple spritebatch, is for when you want to draw certain objects with a different transformation matrix, or other types of spritebatch manipulations. \$\endgroup\$
    – jgallant
    Jan 1, 2012 at 19:57

You must log in to answer this question.

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