const DWTool = require("../utils/DWTool"); cc.Class({ extends: cc.Component, properties: { item: cc.Node, content: cc.Node, }, // LIFE-CYCLE CALLBACKS: onLoad () { }, start () { }, //// 重新判断一下是否可用 updateUI () { for (let i = 0; i < this._items.length; ++ i) { let item = this._items[i]; item.setupGrayBg(item.judgeIsCanUse()); item.setupMaxLevel(); } }, update (dt) {}, init(skillData) { let arr = skillData.skills1.concat(skillData.skills2); this.item.getComponent('SkillItem').initBuilding(skillData.awardCount); this._items = []; // this.skillData = skillData; // this.item.getComponent('SkillItem').init(this, skillData[0]); /// 循环遍历 for(let i = 0; i < arr.length; i++) { let contentItem = cc.instantiate(this.item); this.content.addChild(contentItem); contentItem.active = true; let itemScript = contentItem.getComponent('SkillItem') itemScript.init(arr[i]); this._items.push(itemScript); } } });