1

I have a problem in which in my game I have to use SpriteSortMode.Texture because I have a lot of objects with few textures, so I cannot afford to use SpriteSortMode.BackToFront.

The thing is this means I cannot draw by layers, unless I do SpriteBatch.Begin with the exact same settings, which is what I'm currently doing.

I only have 3 draw layers I need - a Tileset surface, Objects like rocks or characters on the surface, and UI.

Other solutions I've found is using texture quads (which supposedly also improves tileset drawing performance), going 3D with orthogonal view which I haven't researched yet.

I'm hoping there's a better to make this work.

yoavsnake
  • 131
  • 1
  • 5

1 Answers1

0

Why would having a lot of objects with few textures mean you have to use SpriteSortMode.Texture?

"This can improve performance when drawing non-overlapping sprites of uniform depth." says the MSDN page, and this is clearly not what you are doing.

Just use the default SpriteSortMode.Deferred and draw things back to front in order.

Zoltán Király
  • 259
  • 1
  • 12
  • I've tested Deffered or Texture and the difference is huge because I'm using Tiles which are a lot of similar textures, Even though I have multiple layers it's still much better – yoavsnake Feb 27 '18 at 16:58
  • 1
    Well, then I'll take a stab in the dark, a complete guess: what if you put the drawing code for the different layers between their own spriteBatch.Begin() and spriteBatch,End() statements? Maybe even try changing the sort mode in between? – Zoltán Király Feb 27 '18 at 19:08