Jump to content

pixi-layers clarification


Recommended Posts

I'm confused as to why someone would create a group and layer rather than just a layer (which will create a default group if none is given). This part in the documentation I think explains it, but I don't get what's being said:


When you move a character with attached sprites from different layers to a new stage, you have to change their layers.

Instead, you can create a new display Group:

var lightGroup = new PIXI.display.Group();

bunnySprite.parentGroup = lightGroup;
var lightLayer = new PIXI.display.Layer(lightGroup); // only one layer per stage can be bound to same group

Groups are working between different stages, so when you move bunny it will be rendered in its light layer.

Layer is representation of global Group in this particular stage.


Can someone clarify how this API was designed,  or clarify when someone would need a Group to "move between stages?" I'm not exactly sure what this means.




Link to comment
Share on other sites

Thank you for that question! Usually people dont notice that its kind of optional feature.

Its possible to do everything with just a layer, but you might encounter structural problems.

Group is global, you can use it even without any reference to application/stage/whatever. Instead of "element.zIndex=2" you type "element.parentGroup=group2" , group can be used as that number in zIndex, regardless of layer creation.


Edited by ivan.popelyshev
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.

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.
  • Create New...