import { _decorator, Component, instantiate, Node, Prefab } from 'cc'; import { config } from '../../config'; import { add_task_item } from './add_task_item'; const { ccclass, property } = _decorator; @ccclass('add_task') export class add_task extends Component { @property(Node) content:Node = null; @property(Node) btn_close:Node = null; @property(Prefab) item_prefab:Prefab = null; private call_back = null; public show(call){ this.call_back = call; config.task_type_map.forEach((v,k)=>{ let item = instantiate(this.item_prefab) item.parent = this.content; item.getComponent(add_task_item).initView(k,this.onItemClick.bind(this)) }) this.btn_close.on(Node.EventType.TOUCH_END,()=>{ this.close() }) } onItemClick(type:number){ if(this.call_back!=null){ this.call_back(type) } this.close() } close(){ this.node.destroy() } }