2
\$\begingroup\$

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?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ The SpriteBatch is made and optimized for drawing sprites. \$\endgroup\$ Sep 25, 2011 at 16:32
  • \$\begingroup\$ The SpriteBatch is exactly that- an object to batch sprites with. So it's ideal to use that if you want performance. \$\endgroup\$
    – ChrisC
    Sep 25, 2011 at 21:49

1 Answer 1

5
\$\begingroup\$

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.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – DMan
    Sep 25, 2011 at 16:13
  • \$\begingroup\$ 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.. \$\endgroup\$ Sep 25, 2011 at 17:16
  • \$\begingroup\$ 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. \$\endgroup\$
    – Jim
    Aug 10, 2012 at 0:46

You must log in to answer this question.

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