I used a technique that was in an XNA TileEngine tutorial by Nick Gravelyn where a renderlist is created and a sort done based on a comparison between object origins. This all works great between the animated sprites (player, npc's, and mobs) however my issue is with the player and non-animated objects like treasure chests and other items that may be placed. The code pieces I use are listed below, I am trying to figure out how I would also include the BaseSprite class objects. This is done so that when the player passes an npc, mob or object atthe top of that sprite he will be displayed as walking behind it.
private List<AnimatedSprite> renderList = new List<AnimatedSprite>();
private Comparison<AnimatedSprite> renderSort =
// also have BaseSprite chestSprite as non-animated sprite object
BaseSprite chestSprite = new BaseSprite(
new Rectangle(0, 0, 32, 32),
new Point((int)c.Value.X, (int)c.Value.Y));
private static int renderSpriteComapre(AnimatedSprite a, AnimatedSprite b)
public override void Draw(GameTime gameTime)
//draw level code
foreach (AnimatedSprite s in renderList)
Edited by LordRhys, 04 February 2013 - 11:13 AM.