1234567891011121314151617181920212223242526272829303132333435363738 |
- import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
- import { scene_item_data } from '../../../data/data';
- import { show_select_child_scene_item } from './show_select_child_scene_item';
- const { ccclass, property } = _decorator;
- @ccclass('show_select_child_scene')
- export class show_select_child_scene 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(list:scene_item_data[],call){
- this.call_back = call;
- for (let index = 0; index < list.length; index++) {
- const element = list[index];
- let item = instantiate(this.item_prefab)
- item.parent = this.content;
- item.getComponent(show_select_child_scene_item).initView(element,this.onItemClick.bind(this))
- }
- this.btn_close.on(Node.EventType.TOUCH_END,()=>{
- this.close()
- })
- }
- onItemClick(data:scene_item_data){
- if(this.call_back!=null){
- this.call_back(data)
- this.close()
- }
- }
- close(){
- this.node.removeFromParent()
- }
-
- }
|