// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html import EventName from "../EventName/EventName"; import MyComponent from "../Template/MyComponent"; import BarrierDrag from "./barrierDrag"; const { ccclass, property } = cc._decorator; //负责子节点的 层级排序 @ccclass export default class indexManager extends MyComponent { // LIFE-CYCLE CALLBACKS: onLoad() { super.onLoad(); this.regEvent(EventName.UpdataRender, this.up, this) } up() { // //玩家不再编辑中 才排序 // if (!BarrierDrag.PlayEditer && this.node.children.length > 0) { // // this.node.setSiblingIndex(this.node.parent.childrenCount) // for (let index = 0; index < this.node.children.length; index++) { // const element = this.node.children[index]; // let tempBarrierDrag = element.getComponent(BarrierDrag) // if (tempBarrierDrag) { // let MapPos = tempBarrierDrag.getNodeMapPos() // element.zIndex = (200 - (MapPos.x + MapPos.y * 6)) // } // } // } //玩家不再编辑中 才排序 if (this.node.children.length > 0) { // this.node.setSiblingIndex(this.node.parent.childrenCount) for (let index = 0; index < this.node.children.length; index++) { const element = this.node.children[index]; let tempBarrierDrag = element.getComponent(BarrierDrag) if (tempBarrierDrag) { let MapPos = tempBarrierDrag.getNodeMapPos() element.zIndex = (200 - (MapPos.x + MapPos.y * 6)) } } } } onDestroy(): void { super.onDestroy() this.unscheduleAllCallbacks() } // update (dt) {} }