Ahmed Nefzaoui Posted February 9, 2014 Share Posted February 9, 2014 Hello So this is pretty much my very first post in the forums. I do have a question.It's: is there a z-index (which is used in CSS) implementation in Phaser for a tileSprite ?For example if I have two sprites in the same position and how to programatically decide which one I want to be in the front..I'm still learning Pahser's API and quite a beginner so please bear with me Link to comment Share on other sites More sharing options...
polkapunk Posted February 9, 2014 Share Posted February 9, 2014 My understanding is that the sprite which was drawn most recently is in the front, unless you use its bringToTop() method, which will move it to the top of its display list which it's a child of. I'm not sure if there's another way of doing it. I should also mention that there's a method bringToTop() for groups, but unless I'm misreading the documentation, it's only used to bring a specific sprite to the top of the display list for the group, not move the group to the top of the main display list. Ahmed Nefzaoui 1 Link to comment Share on other sites More sharing options...
rich Posted February 9, 2014 Share Posted February 9, 2014 Correct, Group.bringToTop is isolated to that Group specifically. In the latest version of Pixi (which Phaser uses for rendering) they've reverted back to a normal array for the display list. So in Phaser 1.2 you'll be able to just mess with the array to change z-index on the fly, but as it stands in the current master build it's much harder to do well. Ahmed Nefzaoui 1 Link to comment Share on other sites More sharing options...
Ahmed Nefzaoui Posted February 9, 2014 Author Share Posted February 9, 2014 Aha! I understand. Thank you both Also knowing that what comes first goes to the back in order solved it Link to comment Share on other sites More sharing options...
Recommended Posts