Problem in Dynamically reordering zIndex of nodes

Hi,
I am trying to figure out how to change globalZorder of nodes dynamically through code.
I have tried setGlobalZOrder but that seems to be not working or deprecated.

So, i want to know is there any other way to achieve this.

Use setLocalZOrder and parent switching instead of global Z order

Parent switching will be complex in my case, since many actions are dependent on hierarchy of nodes.
It will be messy to do that…
Not any other workaround?

1 Like

How did you find out about the existence of this function ??? It is not in the documentation. It is not even in the file creator.d.ts !!!

http://www.cocos2d-x.org/docs/api-ref/creator/v1.5/classes/Node.html#method_setLocalZOrder

you can also view all methods of any object in javascript using Object.getOwnPropertyNames, for example if you want to know the methods available of a node you can have them written to console like this:

console.log(Object.getOwnPropertyNames(this.node));

->this will also return properties that aren’t functions, to get only functions you can do this:

console.log(Object.getOwnPropertyNames(this.node).filter(function (f) {
    return typeof this.node[f] === 'function';
}));

cheers

@shishir did you find any solution for global render order of nodes? I have same situaton that’s very complex to swith parent of nodes. I need to render some parts in front of everything while still stay same place in hierarchi (like light fx) in my game .

maybe you can use another camera?
then set camera cullmask and node group

about camera : doc : camera

1 Like

My project is on Cocos Creator 1.9.3 and can’t upgrade for now because I customized the engine a lot.

I’ve checked the camer documentation. I’ts good idea but I think we need more optios for camera. Definin a collision group just for camera is not reasonable. I think we need some tag or culling system just for rendering order seperately like in Unity’s sorting layers.

I’ve tested Cocos Creator 2.1.1 using quads with transparent unlit materials and changing Z position of elements works well but we absolutely need something for sprites not for mesh.

emm…
in ccc, node group have two function : render group and collision group!
render group not equal to collision group!

so i think that ccc team maybe should separate render group from collision group!

if you use camera! the node group just like unity sorting layer!
and you don’t even enable collision manager!

and so on! you can try

1 Like

Yes if it’s seperated that would be perfect👍