To change a node’s position among its siblings in Cocos Creator, use setSiblingIndex. Reordering siblings also changes their relative rendering order where sibling order controls drawing.
Suppose you want to move one node immediately after a target node:
1 | const nodeToMove = cc.find("NodeToMove"); |
The code obtains references to both nodes, reads the target’s current index with getSiblingIndex(), and assigns the moving node the following index.
Replace NodeToMove and TargetNode with the paths or names used in your scene. Both nodes must share the same parent for sibling-index ordering to have the intended effect, and you should also guard against either lookup returning null in production code.