add_animation_item.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { _decorator, Color, Component, Label, Node, Sprite } from 'cc';
  2. import { att_ani_data } from '../../../data/data';
  3. import { tools } from '../../tools';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('add_animation_item')
  6. export class add_animation_item extends Component {
  7. @property(Node) lab_name:Node = null;
  8. @property(Node) btn_delete:Node = null;
  9. private call_back = null;
  10. private delete_call_back = null;
  11. private m_data:att_ani_data = null;
  12. private m_index:number =0;
  13. public initView(data:att_ani_data,call,index){
  14. this.call_back = call;
  15. this.m_index = index;
  16. this.m_data = data;
  17. this.lab_name.getComponent(Label).string = this.m_data.ani_name;
  18. this.btn_delete.active = false
  19. this.node.on(Node.EventType.TOUCH_END,()=>{
  20. if(this.call_back!=null){
  21. this.call_back(this)
  22. }
  23. })
  24. this.unSelectStatus()
  25. }
  26. public initViewWithDelete(data:att_ani_data,call,delete_call,index) {
  27. this.initView(data,call,index)
  28. this.delete_call_back = delete_call
  29. this.btn_delete.active = true
  30. this.btn_delete.on(Node.EventType.TOUCH_END, ()=>{
  31. tools.show_dialog('是否删除当前动画',()=>{
  32. if(this.delete_call_back!=null) {
  33. this.delete_call_back(this)
  34. }
  35. })
  36. })
  37. }
  38. public getIndex(){
  39. return this.m_index;
  40. }
  41. public selectStatus(){
  42. this.node.getComponent(Sprite).color = Color.BLUE
  43. }
  44. public unSelectStatus(){
  45. this.node.getComponent(Sprite).color = Color.GRAY
  46. }
  47. public getData(){
  48. return this.m_data;
  49. }
  50. }