-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Children don't undermine their parents #35
Comments
I think you use it the wrong way. Please make a Fiddle and i'll fix it. |
Actually, never mind, its easier to change "container.renderWebGL" method for your body than to use pixi-layers in this case. Can you do that? |
I think you misunderstand, what do you mean by For example, the group I was setting all the parents and children to had priority 3 with a special sort function, when I add 2 more groups, 2.99 and 3.01, I can temporarily achieve what I want: But when they are all in the same group, the children of the sprite doesn't appear below the sprite, while their |
I mean look in the Container source already. Pixi is not a black box. |
https://github.com/pixijs/pixi.js/blob/dev/src/core/display/Container.js#L425 override it and move whatever you need wherever you need. Also, outline will be slow , if you want to use it for more than 10 characters - its better to duplicate each sprite shadow in a different container or level before you draw this thing. |
Don't get this the wrong way, If I had the ability to just look and find the all the answers, I would not be asking these questions, I would just write my own library with some more effort, you have to understand that people who use your library, will usually have a lower understanding of the field than you So let me ask a simpler question:
If the answer is yes, I'm doing something wrong, if the answer is no, I'm missing something, and I'm looking for that thing |
Yes, you can. Make sure that somewhere there is a Layer object with that group where it all will be rendered inside. Its not optimal. I advice you to look at how everything works and look for stupid solutions. |
Test this here: https://pixijs.io/examples/#/layers/zorder.js It doesn't work
This works |
Btw I dont know what line Oh, right its a known bug. If parent and child belong to the same group, then child is rendered twice - one as a mamber of a group and one as a child of that parent. I dont know how to fix that fast, and its the first time someone actually encountered it :) |
Well If you started your own Patreon, I'd join :) Other than that, my capabilities are beyond it, if it will be a long living bug, I'd probably work around it - for this specific occurrence, I think it'd be better if I turned the Sprite itself into a Container, and manually sort things inside, it's a better solution anyway But I do come up with a lot of weird in-between stages in development that calls for having the child and parent having the same layer, for example, think of a small ball circling around a player object, someone using pixi-layers could just want to experiment with such a thing, and would stumble onto this bug again You sometimes just want to add something to a Sprite, and practically make it appear under the Sprite, you know, even if it's a child |
Ok, you've got me, I'm gonna fix it right now. |
YEAH IT WORKS! Try to add this thing somewhere on top of your code: PIXI.Container.prototype.renderWebGL = function (renderer) {
if (this._activeParentLayer && this._activeParentLayer != renderer._activeLayer) {
return;
}
if (!this.visible) {
this.displayOrder = 0;
return;
}
this.displayOrder = renderer.incDisplayOrder();
if (this.worldAlpha <= 0 || !this.renderable) {
return;
}
renderer._activeLayer = null; // < -- this is my temporary change
this.containerRenderWebGL(renderer);
renderer._activeLayer = this._activeParentLayer; // < -- and this one too
} |
Got it , please look again. |
Thanks :) Tested it, for me, it made the child sprites disappear (On the pixi/examples fiddle it works tho) So my actual use case differs from the fiddle somehow |
hum, if i remember on my side , the what append if you do ? s1.parentGroup = $displayGroup.group[id];
s1.zIndex = 10;
s2.parentGroup = $displayGroup.group[id];
s2.zIndex = 15; suppose s1 and s2 are containers or sprites inside a stage container, and your stage have |
@djmisterjon sort direction is different for |
I encountered this but thought it was becasue I was doing something wrong 👍 Two groups Two display Layers
Everything in my world layer is being drawn twice. |
EDIT: I'm sorry for anyone that tried to use the first part of what I posted. It had some changes to it based on some things I add to every build of pixi I do. I changed the code to work properly without any kind of extras. Also those changes were not compatible with pixi-lights so I had to go through and undo them myself and remembered this comment! I should have clarified that the temp solution didnt work for me either. These changes worked for me for now. Not sure if they will work for you for the time being :) All this does is limit an object to one render per 'frame'. For me it seemed like the 'normal' child drawing was always happening before the sorted array so I set it up to always return on the first attempt and allow any further attempts. It is possible to have things draw more than twice depending on how you set them up. In which case you will have to modify this tmporary solution. Your milage may vary. Replace this at the top of your dist file
Replace this at the bottom of your dist file
|
So I'm experiencing this problem right now:
[1-Major] Basically, no matter what I tried, I couldn't make childrens of a sprite, appear below the sprite (they are on the same layer, aka,
PIXI.DisplayGroup
) - so basically I want wings to appear behind the body, but just doesn't happen[2-Minor] I had pixi-layers 0.1.7 - now I got the latest 0.1.7 - it's a lengthier one, has some
sortPriority
code - I tried setting it to several places but didn't change anything - I think the version should've increased it at one point, to 0.1.8[3-Major-Opinion-Request] I could solve this problem with tools at hand, make the body a children of the container, rather than the container itself, but looking for the optimal solution, I also apply filters to the body, I want the additional parts like the head etc. to have the filters too, if they were actually one Sprite, this would be the case, but I'm guessing there's no actual solution to this problem now? Example: If I applied an outline filter to sprites, the head and body will be outlined individually now?
The text was updated successfully, but these errors were encountered: