lasertown Posted May 26, 2020 Share Posted May 26, 2020 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: Quote 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. Thanks, Mike ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
jonforum Posted May 26, 2020 Share Posted May 26, 2020 Hi, here a basic user case of groupshttps://pixijs.io/examples-v4/#/plugin-layers/normals-drag.js Also using on my side, here another user case. https://github.com/djmisterjon/ANFT/blob/master/js/game/global/displayGroups.js I have no more example or good explanation in English sorry. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 26, 2020 Share Posted May 26, 2020 (edited) 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 May 26, 2020 by ivan.popelyshev jonforum 1 Quote Link to comment Share on other sites More sharing options...
lasertown Posted May 26, 2020 Author Share Posted May 26, 2020 Ok I think I understand the intention now, thanks Ivan! ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.