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.

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!

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
1  
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. –  Jon Jan 1 '12 at 19:57
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.