import ItemIconTouchScript from "./ItemIconTouchScript"; const { ccclass, property } = cc._decorator; @ccclass export default class ItemIconList extends cc.Component { @property(cc.Node) itemIcon: cc.Node = null; @property(cc.Node) content: cc.Node = null; start() { this.itemIcon.active = false; } setIconListData(iconList: any[], checkNodeList: cc.Node[], targetNodeList: cc.Node[]) { //console.log("1+++++++++++++++++++++++++>"); let iconListData = []; for (let index = 0; index < iconList.length; index++) { let data_ = { iconIndex: index, touchName: iconList[index].name, bandleName:iconList[index].bandleName, picPath: iconList[index].url, checkNode: checkNodeList[index], targetNode: targetNodeList[index] }; iconListData.push(data_); } //console.log("2+++++++++++++++++++++++++>"); for (let index = 0; index < iconListData.length; index++) { let aInt = Math.trunc(Math.random() * iconListData.length); let random = iconListData[aInt]; iconListData[aInt] = iconListData[index]; iconListData[index] = random; } //console.log("3+++++++++++++++++++++++++>"); for (let i = 0; i < iconListData.length; i++) { let itemIconNode = cc.instantiate(this.itemIcon); itemIconNode.active = true; this.content.addChild(itemIconNode); let scr: ItemIconTouchScript = itemIconNode.getComponent('ItemIconTouchScript') scr.setTouchNodeIcon(iconListData[i]); } } // update (dt) {} }