Sprite Draw Order issue

Hi, I’m trying to render a sprite above another sprite. I need to do that dynamically in my code but this logic is not working.

I’m enabling random 2D trees and the new enabled tree should be behind the already enabled trees.

this.drawOrderIndex–;
disabledTrees[i].sprite.drawOrder = this.drawOrderIndex;
disabledTrees[i].reparent(this.parentObj,0);

Can someone help me, please?

Thanks in advance

The API documentation needs updating. For drawOrder to work, the layer that the sprites are in need to have a manual sorting order.

1 Like