Sprite sorting issues
Posted
by
TheBroodian
on Game Development
See other posts from Game Development
or by TheBroodian
Published on 2012-06-21T00:12:35Z
Indexed on
2012/06/21
3:26 UTC
Read the original article
Hit count: 250
I apologize for the vague title, I'm not sure how else to phrase this problem.
I am using tIDE to assist me in my game's world development. To give a dynamic effect to map layers within tIDE, it has events that can be wired up to draw sprites before or after the draw of layers, to create foreground or background effects during runtime. This all works fine and well, however, the only way that I understand that this works, is by calling tIDE's internal spritebatch to create this effect. This creates a problem for me, because within tIDE's source code, its spritebatch's call block is set to SpriteSortMode.Deferred, and my characters have particle elements that I would like to draw in front of and behind themselves, via a drawdepth value.
I can use a separate instance of spritebatch and call my character's draw method, and set sprite sorting there, but then my character is drawn ontop of all layers in my tIDE map. Which is even worse to me than my particles not being drawn as I want them to be.
So, in summary, I want all of my crap to work, but at the moment the only way I can figure to do that is to ghetto rig the spritebatch within my characters' draw methods by calling a spritebatch.End();, then starting a new call to Begin() with SpriteSortMode.BackToFront, doing all of my characters' draw logic, and then calling another spritebatch.End(); followed once again by a new spritebatch.Begin().
Obviously that is pretty undesirable, but I don't know any other feasible alternatives. Anybody got any wisdom they could impart unto me as to how I could handle this?
© Game Development or respective owner