Jump to content

z-index implementation?


Ahmed Nefzaoui
 Share

Recommended Posts

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

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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