import { _decorator, Color, Component, Label, Node, Sprite } from 'cc'; import { att_ani_data } from '../../../data/data'; import { tools } from '../../tools'; const { ccclass, property } = _decorator; @ccclass('add_animation_item') export class add_animation_item extends Component { @property(Node) lab_name:Node = null; @property(Node) btn_delete:Node = null; private call_back = null; private delete_call_back = null; private m_data:att_ani_data = null; private m_index:number =0; public initView(data:att_ani_data,call,index){ this.call_back = call; this.m_index = index; this.m_data = data; this.lab_name.getComponent(Label).string = this.m_data.ani_name; this.btn_delete.active = false this.node.on(Node.EventType.TOUCH_END,()=>{ if(this.call_back!=null){ this.call_back(this) } }) this.unSelectStatus() } public initViewWithDelete(data:att_ani_data,call,delete_call,index) { this.initView(data,call,index) this.delete_call_back = delete_call this.btn_delete.active = true this.btn_delete.on(Node.EventType.TOUCH_END, ()=>{ tools.show_dialog('是否删除当前动画',()=>{ if(this.delete_call_back!=null) { this.delete_call_back(this) } }) }) } public getIndex(){ return this.m_index; } public selectStatus(){ this.node.getComponent(Sprite).color = Color.BLUE } public unSelectStatus(){ this.node.getComponent(Sprite).color = Color.GRAY } public getData(){ return this.m_data; } }