How to define the rendering depth order of two sprites sharing the same SpriteManager?

Regarding this question: Texture looks jagged with white background

We’ve seen to set the rendering depth order of two SpriteManagers is made using the renderingGroupId property.

In case I have two sprites that are sharing the same SpriteManager, I’ve seen that the render depth order is set by the sprite creation order. That can lead to rendering issues if the creation order doesn’t match the render (or camera) depth order.

Example where sprite creation order matches the depth order, antialias is applied:

Example where sprite creation order is inverse to the depth order, antialias not applied (jagged edges):

Is there a way to set their rendering depth order using a property, and not being forced to create the sprites in the same depth order?
I don’t find a sprite property similar to renderingGroupId.

Their depth order can change depending on the game situation, so I’d need to set it up manually. Creating an exclusive SpriteManager per sprite could be a big loss of memory.

You can access the list of sprites through SpriteManager.sprites and sort the array according to the distance of each sprite to the camera.

For eg:

1 Like

Cool! Thanks!