frame_item.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { _decorator, Color, Component, Label, Node, Sprite } from 'cc';
  2. import { ani_frame } from '../../../data/data';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('frame_item')
  5. export class frame_item extends Component {
  6. @property(Node) frame_name:Node = null;
  7. private m_data:ani_frame = null;
  8. private m_call_back = null;
  9. private m_index = 0;
  10. public initView(data:ani_frame,call,farme_index:number){
  11. this.m_data = data;
  12. this.m_call_back =call;
  13. this.m_index = farme_index;
  14. this.frame_name.getComponent(Label).string = `第${farme_index}帧`
  15. this.node.on(Node.EventType.TOUCH_END,()=>{
  16. if(this.m_call_back!=null){
  17. this.m_call_back(this)
  18. }
  19. })
  20. }
  21. public getIndex(){
  22. return this.m_index;
  23. }
  24. public getData(){
  25. return this.m_data;
  26. }
  27. public setData(data:ani_frame){
  28. this.m_data = data;
  29. }
  30. public selectStatus(){
  31. this.node.getComponent(Sprite).color = Color.GREEN;
  32. }
  33. public unSelectStatus(){
  34. this.node.getComponent(Sprite).color = Color.WHITE;
  35. }
  36. }