XNA Spritebatch question(s)

Started by
2 comments, last by 6677 11 years, 9 months ago
My second question may be more important but what that is depends on the answers to my first questions. That is, why is Spritebatch set up so that when drawing, Vector2.Zero refers to the upper left corner instead of the center of the screen and why are positive Y coordinates below this origin instead of above?

Having it set up this way isn't a big deal in itself but it doesn't seem consistant with the way XNA does anything else by default, such as mesh drawing and the 360 pad thumbstick vector2s.
Advertisement
XNA isn't the only API which does this. Almost all 2D APIs do this.
The SpriteBatch class is designed with 2D in mind. Meaning, if you have ever worked with 2D graphics before, you would see that it is much easier to refer to things from a corner of the screen. (btw, you can apply a transform matrix in SpriteBatch.Begin(...) to offset your coordinates)
3D is based on perspective projection - meaning convergence to the center point of the viewport - so it is easier to work from the center and offset things depending on how much focus you want the player to have on them.
On the other hand, 2D is based on parallel-orthographic projection - meaning the entire viewport is viewed from the same distance - so the user should be focused on the entire scene, making it easier to work with from a corner (a relatively insignificant spot)

(btw, you can apply a transform matrix in SpriteBatch.Begin(...) to offset your coordinates)

Which I have done and so this will be my second question; what are my options with the translation Matrix I provide to Spritebatch? Would it be possible to flip the Y coordinates upside down? Can this be done without reversing the X? Would I have to flip all my textures to accomidate?

The issue is, my game is mainly 3D but for [s]debugging[/s]* and level editing, I use a combination of both 3D and 2D. I can manipulate my 3D data to account for the Spritebatch, it's nothing hard to figure out but if it's possible, I'd much rather manipulate the Spritebatch to account for how my 3D is already working.

*I mean designing and tweaking the game with my debug build. Nothing related to the spritebatch code is part of the Release build, which is why I feel It'd be better to make it work like the rest of the game.
You could define your own wrapper class around spritebatch that deals with the inversion of the y axis for you.

This topic is closed to new replies.

Advertisement