wojo1086 Posted May 5, 2017 Share Posted May 5, 2017 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 More sharing options...
samme Posted May 5, 2017 Share Posted May 5, 2017 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 More sharing options...
wojo1086 Posted May 5, 2017 Author Share Posted May 5, 2017 If I move the text into a different layer, that would mean it can't be a child of the sprite. Is that correct? Link to comment Share on other sites More sharing options...
RubbleGames Posted May 6, 2017 Share Posted May 6, 2017 You can mimic the behaviour of a child object, for example have child.x = sprite.x etc in your update function and code the child to be removed when the sprite is. I'm not sure how good an idea this is from a performance point of view though. Link to comment Share on other sites More sharing options...
samme Posted May 7, 2017 Share Posted May 7, 2017 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 More sharing options...
Recommended Posts