Usually XNA increases X coordinate to right and Y to down. Like this:


But in my project i have 2D map. Drawing tile with bigger Y coodinate below OX looking strange (usually people imagines these tiles above OX).

Yeah i can just use

spriteBatch.Draw(Turf.Texture, new Rectangle(Turf.X*32, Turf.Y*32*-1),Color.White);

//32 is width and height of tile, also code simplified

But it makes a code harder and uglier. Don't XNA have any setting \ variable to make spritebatch counting Y to top?


1 Answer 1


alternatively you can create your own functions to do it, like:

void drawSprite(Texture2D texture, Rectangle rect, Color color)
    spriteBatch.Draw(texture, new Rectangle(/*modifying the given rectangle*/), color);
  • \$\begingroup\$ this is bad idea because my draw code already difficult and can't be modificied so easy \$\endgroup\$
    – cat
    Nov 29, 2015 at 13:10
  • 4
    \$\begingroup\$ Why would this be a bad idea? It creates the alternate coordinate system separate from your existing code. You could even create the function as an extension of SpriteBatch. This way the complexity is not added to yor existing functions. In fact this is I think the only way of doing what you ask. You seem to want your own coordinate system, because reversing the Y axis (which you can accomplish by initializing the spritebatch using a Matrix) would also flip your sprites upside down. \$\endgroup\$
    – Felsir
    Nov 30, 2015 at 18:04

You must log in to answer this question.

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