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'm designing a platformer and beginning to code the viewing engine of the game. Now, I have to make a key decision: Should I just use SpriteBatch to draw all the 2D stuff, as there is no 3D, or should I just go with making camera-facing polygons with Z set to zero? What are the good sides and drawbacks of both? Performance? Extensibility?

Performance is a key factor as I'll be having lots of texttures/objects/effects/animations etc, and I'll be targetting high resolutions like 1920x1200 (if available on client's computer), so I need things to go smooth. On the other hand, I also need some extensibility, as I want to have great control over the drawing methods. Seems like I'd be going with 3D/polygon method, but I was wondering if it has any side-effects?

share|improve this question
1  
The SpriteBatch is made and optimized for drawing sprites. –  Jonathan Connell Sep 25 '11 at 16:32
    
thanks, I'll be going with that one. –  Can Poyrazoğlu Sep 25 '11 at 17:17
    
The SpriteBatch is exactly that- an object to batch sprites with. So it's ideal to use that if you want performance. –  ChrisC Sep 25 '11 at 21:49

1 Answer 1

up vote 5 down vote accepted

Sprite batch is implemented with 'camera-facing polygons with Z set to zero'. IIRC it even has rotation, and if it doesn't, you can supply your own transformation matrix. Your choices are equivalent. Ask yourself how much work you want to do duplicating spritebatch instead.

share|improve this answer
1  
This is correct; I guess there may be some overheads of SpriteBatch hidden somewhere, but it is essentially still hardware accelerated, which means it must be drawn as 3D. SpriteBatch gives you functionality like assembling the texture onto polygons for free, so don't rewrite it. –  DMan Sep 25 '11 at 16:13
    
ok thanks, I'll be going with SB then.. I just wanted to be sure that I could have the flexibility to rotate and scale. well, using a transform matrix, I'll probably achieve what I want.. –  Can Poyrazoğlu Sep 25 '11 at 17:16
    
SpriteBatch can optionally take a float that defines rotation, a vector2 that defines where the origin to rotate around is, and a SpriteEffects enum flag that allows for horizontal/vertical flipping. –  Jim Aug 10 '12 at 0:46

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.