-
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
add sprite to layers ? #23
Comments
Ok, imagine that you have a stage, and layer+container inside. var stage = app.stage ; //new PIXI.display.Stage();
var layer = new PIXI.display.Layer();
var container = new PIXI.Container();
var sprite = new PIXI.Sprite();
stage.addChild(layer);
stage.addChild(container);
container.addChild(sprite); You tell sprite inside container that it has to be rendered inside layer: sprite.parentLayer = layer; before rendering, sprite is added to special list of layer:
now sprite will be rendered inside layer instead of his parent container. The question is: what are groups and why do we need them here? Imagine that you have a function that creates a composite element: function createCharacter() {
var char = new PIXI.Container();
var shadow = new PIXI.Sprite();
var body = new PIXI.Sprite();
char.addChild(shadow);
char.addChild(body);
shadow.parentLayer = shadowLayer;
return char;
} Body is rendered in natural order, but shadow is rendered in shadow layer behind everything else. The problem is that function might have no access to stage or layer Stage or layers can be re-created every time you load new level. We need something independent from them - that's a group.
Group is global constant, its a marker. |
Why dont I use numbers (z-index) to mark things instead of groups? That's my original idea: its easier to mark with objects because we can use this object as a temporary bucket to sort all things inside. Imagine that we have 1000 objects, and 2 are special: one is behind everything and one is above. With my approach, these are three groups: one behind, one above and one that has rest of elements (998), we sort only 3 groups. In naive, we have 1000 elements that we have to sort by z-indices. Sort(3) or Sort(1000) , which one is faster? |
ok ok thank a lot , this help me a lot to understand. var groupMap = new PIXI.display.Group(0, true); // all elements on map
var groupGui = new PIXI.display.Group(1, true); // all GUI over the map
var groupMenu = new PIXI.display.Group(2, true); // all ,menu over the map and gui I will try to study and translate a little more what you your say upper and make more test. |
You dont have to enable sort inside every group, you can pass second param as |
ok tank. I keep you updated... |
@ivanpopelyshev Example here, I have a special house, that the player will be able to move on the roof. The character is assigned by default at level 0, for the moment all is well. If I want to jump up the character on the roof, I can easly transfer it to level 2 The problems begin at the moment when there is superposition of 2 levels on the character. I wonder if this shows the limit of your plugin, or it is possible to find a small hack to work around the problem, without radically making too complicated the process. to make this kind of sprite I will probably map to photoshop and use the atlas to export with texturePacker. |
I have a solution but it is not packaged into a plugin, and its hardcore. The problem is that you have to do topological sort for objects, it cant be done with The main feature of my plugin is sorting by layers and within the layer you can do your own stuff. If i give you the code, I also would have to spend some time explaining how it works and I certainly dont have time right now. May be in a month. Try do some hacks for now, use both Y and Z in sorting that suits your case. The problem is that for every solution you can also imagine a new case that breaks it :) |
The thing you are asking is a hard work and certainly is behind the limits of pixi open-source space. People pay me for that kind of solutions suited for specific projects, and I'm working on one right now. |
We can try collaborate on it in a month or two :) |
ok, i'll try some hack and different technique. split characters in 2 part (the upper body alway have +1 level) or maybe something like that. here a very small example for give a idea if (!this._upperBody) {
this._upperBody = new Sprite();
this._upperBody.anchor.x = 0.5;
this._upperBody.anchor.y = 1;
this.addChild(this._upperBody);
}
if (!this._lowerBody) {
this._lowerBody = new Sprite();
this._lowerBody.anchor.x = 0.5;
this._lowerBody.anchor.y = 1;
this.addChild(this._lowerBody);
} but the real issue are all my game made with Spine. |
where to find a way to assign a value to the bones.| |
yeah, that's why its that difficult. And I actually have code that can split sprites and render them, without extra Sprite instances. Its just, its not production-ready and it would be very difficult to setup in your project, we need to work with it in more controlled environment first, and I have to spend time e.t.c. :) |
well my problem are solved, i experimente different solution with my map editor, and everything is simply happening in a good management of the pivots in the workflow. I will also add switches on some sprites, which will be transferred to the layer at the same time as the heroes. thank you very much for your suggestions and your plugin, I hope that you continue to improve it, is very well done. |
You are the master of pivots! |
@ivanpopelyshev
hey, thank you first and bravos.
I just rewrote all Update core Rmmv with pixi-display.js
Your plugin allows me to get amazing performances in my little project RMMV!
Performance && setup preview:
https://youtu.be/8oGkRMTnReQ
Now my project can old more than 400 interactive events on a map with spines
Before only 100!! and a lot fps drop with the basic rmmv z rendering core.
My actual config on my map are:
i have question about how add i can add elements to a layer groups
in my example i have
why i can add specific element to lG_groupMap
example i need to do
full code experimental code
thank for help if you have time
The text was updated successfully, but these errors were encountered: