Swap and swapChildren in group

Recommended Posts

Hi Everyone, 


I'm trying to understand what swap() and swapChildren() methods in group do. Can they be used to swap X and Y positions of children in group?

The example here only seems to swap the Z position. Should I update X and Y position manually or does phaser has a method for that?



Share this post

Link to post
Share on other sites

They swap children on the display list, so yes, z-index only. There's no concept of x or y in a display list, that's a userland level sort really (i.e. do it in your own code). The Group.sort method could help though.


Thank Rich. By reading the API, I thought they might swap the X and Y positions too. 


Also, thank you so much for the awesome framework and all the support you are providing for it.  :)

Share this post

Link to post
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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.