Sprite sorting?
Posted: Mon Jul 14, 2008 4:34 am
I'm writing a dynamic sprite list routine, and need to sort the list.
I'm curious to find out what value everyone would sort on?
My thought would be the bottom on the sprite. This assumes that the sprite data is justified to the bottom of the sprite, and sprites always appear on the ground (no sprite is floating). There would be a problem with layering of sprites at the same location.
A 'z' position might be better. The only issue I can see is finding a way to ensure a sprite can draw over the top of another sprite, but not draw over a higher priority sprite. For example, the explosion of a sprite should show over the sprite, but not draw over any other sprite at the same level, that is a higher priority. I guess I could have a sprite attachment field, and not sort the attachments. This would also have the advantage of allowing multiple attachments to a sprite, and the order of the attachments could be controlled, similar to the sprite link field. And, the position of the attachment would be automatically controlled.
I'm curious to find out what value everyone would sort on?
My thought would be the bottom on the sprite. This assumes that the sprite data is justified to the bottom of the sprite, and sprites always appear on the ground (no sprite is floating). There would be a problem with layering of sprites at the same location.
A 'z' position might be better. The only issue I can see is finding a way to ensure a sprite can draw over the top of another sprite, but not draw over a higher priority sprite. For example, the explosion of a sprite should show over the sprite, but not draw over any other sprite at the same level, that is a higher priority. I guess I could have a sprite attachment field, and not sort the attachments. This would also have the advantage of allowing multiple attachments to a sprite, and the order of the attachments could be controlled, similar to the sprite link field. And, the position of the attachment would be automatically controlled.