我尝试了zIndex和setLocalZOrder,都没成功。我的情况是这样:有两个独立的node:a,b;node a下面有个子节点c,目前的绘制顺序是a-c-b,我想要的绘制顺序是a-b-c,请问要怎么做。
粘上我写的代码:
//dianti.js
cc.Class({
extends: cc.Component,
properties: {
dianti: {
default: null,
type: cc.Sprite
}
},
// use this for initialization
onLoad: function () {
//this.node.zIndex = 10;
this.node.setLocalZOrder(10);
//this.dianti.node.zIndex = 30;
this.dianti.node.setLocalZOrder(30);
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
//people.js
cc.Class({
extends: cc.Component,
properties: {},
// use this for initialization
onLoad: function () {
this.node.on("touchstart", ()=>{
cc.director.getScene().removeChild(this.node);
this.destroy();
});
//this.node.zIndex = 20;
this.node.setLocalZOrder(20);
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});