import { _decorator, Component, instantiate, Node, Prefab } from 'cc'; import { att_question_select, event_item_show_question_select, event_item_show_question_select_item } from '../../../data/data'; import { btn_question_item } from './btn_question_item'; import { gameManager } from '../gameManager'; const { ccclass, property } = _decorator; @ccclass('question_select') export class question_select extends Component { private m_data:att_question_select = null; @property(Prefab) btn_question:Prefab = null; private mCallBack = null; public initView(data:att_question_select,event_data:event_item_show_question_select,call){ this.m_data = data; this.mCallBack = call; this.node.destroyAllChildren(); this.node.removeAllChildren(); for (let index = 0; index < this.m_data.btn_question_list.length; index++) { const element = this.m_data.btn_question_list[index]; let item = instantiate(this.btn_question) item.parent = this.node; item.getComponent(btn_question_item).initView(element,event_data.question_list[index],index,this.onItemClick.bind(this)) } } onItemClick(item:event_item_show_question_select_item){ if(this.mCallBack!=null){ this.mCallBack(item) } gameManager.Singleton.sys_click_button_music() } }