add_animation_item.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { _decorator, Color, Component, Label, Node, Sprite } from 'cc';
  2. import { att_ani_data } from '../../../data/data';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('add_animation_item')
  5. export class add_animation_item extends Component {
  6. @property(Node) lab_name:Node = null;
  7. private call_back = null;
  8. private m_data:att_ani_data = null;
  9. private m_index:number =0;
  10. public initView(data:att_ani_data,call,index){
  11. this.call_back = call;
  12. this.m_index = index;
  13. this.m_data = data;
  14. this.lab_name.getComponent(Label).string = this.m_data.ani_name;
  15. this.node.on(Node.EventType.TOUCH_END,()=>{
  16. if(this.call_back!=null){
  17. this.call_back(this)
  18. }
  19. })
  20. this.unSelectStatus()
  21. }
  22. public getIndex(){
  23. return this.m_index;
  24. }
  25. public selectStatus(){
  26. this.node.getComponent(Sprite).color = Color.BLUE
  27. }
  28. public unSelectStatus(){
  29. this.node.getComponent(Sprite).color = Color.GRAY
  30. }
  31. public getData(){
  32. return this.m_data;
  33. }
  34. }