1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
- import { att_ani_data } from '../../../data/data';
- import { add_animation_item } from './add_animation_item';
- const { ccclass, property } = _decorator;
- @ccclass('select_animation')
- export class select_animation extends Component {
- @property(Node) content:Node = null;
- @property(Node) btn_close:Node = null;
- @property(Prefab) item_prefab:Prefab = null;
- private call_back = null;
- private m_list:att_ani_data[] = []
- public show(list:att_ani_data[],call,id:number=-1){
- this.m_list = list;
- this.call_back = call;
- for (let index = 0; index < this.m_list.length; index++) {
- const element = this.m_list[index];
- let item = instantiate(this.item_prefab)
- item.parent = this.content;
- item.getComponent(add_animation_item).initView(element,this.onItemClick.bind(this),index)
- if(id===element.ani_id){
- item.getComponent(add_animation_item).selectStatus()
- }
- }
- this.btn_close.on(Node.EventType.TOUCH_END,()=>{
- this.close()
- })
- }
- onItemClick(item:add_animation_item){
- if(this.call_back!=null){
- this.call_back(item.getData())
- }
- this.close()
- }
- close(){
- this.node.destroy()
- }
- }
|