You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.7 KiB
51 lines
1.7 KiB
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) {}
|
|
}
|
|
|