| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- const { ccclass, property } = cc._decorator;
- /**
- * 签到条目 数据分发
- * @author 薛鸿潇
- */
- @ccclass
- export default class NewClass extends cc.Component {
- @property({ type: cc.Node, displayName: '位置组件' })
- private sign_icon_pos: cc.Node[] = [];
- @property({ type: cc.Prefab })
- private pre_icon: cc.Prefab = null!;;
- /** icon节点容器 */
- private arr_icon: Array<cc.Node> = [];
- onLoad() {
- }
- start() {
- }
- /**
- * list_data
- * @param list_data 数据列表
- */
- public async setItemData(list_data) {
- await this.initItem(list_data);
- }
- /**
- * 数据分发
- * @param list_data 数据列表
- */
- private initItem(list_data) {
- const n_count = this.sign_icon_pos.length;
- for (let i = 0; i < n_count; i++) {
- let item_data = list_data[i];
- let icon_item = this.arr_icon[i];
- if (!icon_item) {
- icon_item = cc.instantiate(this.pre_icon)
- icon_item.parent = this.node;
- icon_item.setPosition(this.sign_icon_pos[i].getPosition());
- this.arr_icon[i] = icon_item;
- }
- let comp_info = icon_item.getComponent('SignIconItem');
- comp_info.setItemData(item_data);
- }
- }
- // update (dt) {}
- }
|