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.
65 lines
2.1 KiB
65 lines
2.1 KiB
import ItemIconBTouchScript from "./ItemIconBTouchScript";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class ItemIconBList extends cc.Component {
|
|
|
|
@property(cc.Node)
|
|
itemIcon: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
content: cc.Node = null;
|
|
|
|
start() {
|
|
this.itemIcon.active = false;
|
|
}
|
|
|
|
setIconListData(iconListConfig: any, checkListNode: cc.Node[], targetNodeList: cc.Node[]) {
|
|
let iconListData = [];
|
|
for (let arr = 0; arr < iconListConfig.length; arr++) {
|
|
let checkNodeArray = [];
|
|
if (checkListNode[arr].children.length > 0) {
|
|
checkNodeArray = checkListNode[arr].children;
|
|
for (let index = 0; index < checkNodeArray.length; index++) {
|
|
checkNodeArray[index].attr({
|
|
targetNode: targetNodeList[arr].children[index]
|
|
});
|
|
}
|
|
} else {
|
|
checkListNode[arr].attr({
|
|
targetNode: targetNodeList[arr]
|
|
});
|
|
checkNodeArray.push(checkListNode[arr]);
|
|
}
|
|
|
|
let data_ = {
|
|
index: arr,
|
|
name: iconListConfig[arr].name,
|
|
url: iconListConfig[arr].url,
|
|
bandleName:iconListConfig[arr].bandleName,
|
|
checkNodeArray: checkNodeArray,
|
|
};
|
|
|
|
iconListData.push(data_);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
for (let index = 0; index < iconListData.length; index++) {
|
|
let itemIcon = cc.instantiate(this.itemIcon);
|
|
itemIcon.active = true;
|
|
this.content.addChild(itemIcon);
|
|
|
|
let scr: ItemIconBTouchScript = itemIcon.getComponent('ItemIconBTouchScript')
|
|
scr.setTouchNodeIcon(iconListData[index]);
|
|
}
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|
|
|