Arcanorum Posted February 7, 2015 Share Posted February 7, 2015 So I have a player class that extends from sprite, and I have added another sprite to it as a child.The child that is added is always in front of the sprite of the parent. Given that sprites can be used like groups, which is what I am doing here, it seems as if the parent's sprite itself isn't taken into account when reordering children draw orders. How do I make the sprite of the parent appear above the sprites of it's children? Link to comment Share on other sites More sharing options...
joey Posted February 16, 2015 Share Posted February 16, 2015 From the phaser examples: // Items are rendered in the depth order in which they are added to the Group I don't know of any way to get around this. You could either make the second sprite not be a child of that class, or have it be another instance of the class that is added before the first sprite. Link to comment Share on other sites More sharing options...
Triplanetary Posted February 16, 2015 Share Posted February 16, 2015 Have you tried calling .bringToTop() on the parent sprite? Link to comment Share on other sites More sharing options...
ForgeableSum Posted March 2, 2015 Share Posted March 2, 2015 I'm running into this issue as well. Can't seem to get a child sprite to display behind its parent. Phaser do you even shadow? Link to comment Share on other sites More sharing options...
Eraph Posted June 7, 2015 Share Posted June 7, 2015 Did you ever find a solution for this? .bringToTop() seems to bring the sprite + its children to the top relative to sprites not in that sprite group. I'm using the .addChild() method of a sprite to keep them grouped together, rather than an actual group which doesn't seem to be quite what I'm after. Link to comment Share on other sites More sharing options...
Eraph Posted June 7, 2015 Share Posted June 7, 2015 After mucking about with this I settled on a sort of hacky workaround. Basically you declare the sprite without specifying the key for the image to use, so basically starting with an empty sprite. Add the child sprites you want to appear behind the main sprite, and then add the main sprite as a child last. Does the trick for me. drinkdecaf and liakos1992 2 Link to comment Share on other sites More sharing options...
ForgeableSum Posted March 6, 2016 Share Posted March 6, 2016 There's still not a real solution to this? If sprites are being treated as groups, should they not have sorting functionality? tidelake 1 Link to comment Share on other sites More sharing options...
samme Posted March 23, 2017 Share Posted March 23, 2017 This is just how a display tree works. If you need a Group, use a Group. If you need a Sprite, create a Sprite from a transparent image identical to the "main sprite" size, then add the main sprite and reorder all you like. gauravD 1 Link to comment Share on other sites More sharing options...
Recommended Posts