Do you mean like having multiple images being children of a single Sprite, and ensuring that one of the images is at top ? If so then since images are drawn by order of additions into the parent sprite, then just add the top-most in the last position.
If you want to change the z order relative to a parent you can try something like this:
function myClass:toFront()
self:getParent():addChild(self)endfunction myClass:toBack()
self:getParent():addChildAt(self, 1)endfunction myClass:setZ(index)local parent=self:getParent()local n=parent:getNumChildren()if index>n then
parent:addChild(self)elseif index<1then
parent:addChildAt(self, 1)else
parent:addChildAt(self, index)endend
If you have lots of sprites being generated in your game loop, you'll need to call the toFront function every frame or add any new sprites behind it when they are created - addChildAt(self, 1).
Remember it won't work very well for "nephew"/"uncle"/"cousin" relationships. You'll need to work out some logic between the parents or use empty sprites.
Comments
Remember it won't work very well for "nephew"/"uncle"/"cousin" relationships. You'll need to work out some logic between the parents or use empty sprites.