Jump to content

Is there a way to make a child of a sprite sit at a higher z-index?


wojo1086
 Share

Recommended Posts

Hello all!

 

I have a sprite with some children, 3 sprites and a text. The text floats above the sprite and moves with it. I have 4 layers that in my map and the sprite is rendered after layer 2. The problem is that the text ends up behind part of the map that sits in layers 3 and 4. Is there a way to force the text to the top of everything?

Link to comment
Share on other sites

You can only reorder objects at the same level of the render tree. So you have to either move the text into the layer holding map layers 3 and 4 and then raise it or find the text's ancestor in the same layer and raise it.

You can print the tree with game.debug.displayTree().

Link to comment
Share on other sites

On 5/5/2017 at 2:56 PM, wojo1086 said:

If I move the text into a different layer, that would mean it can't be a child of the sprite. Is that correct?

Right, it would be the child of another Group instead.

It should work fine if you do something like

// update():
spriteText.position.copyFrom(sprite.position);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...