btn_question_item.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { _decorator, Component, Node, UITransform, Vec3 } from 'cc';
  2. import { event_item_show_question_select_item, ui_att_item } from '../../../data/data';
  3. import { gameManager } from '../gameManager';
  4. import { tools } from '../../tools';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('btn_question_item')
  7. export class btn_question_item extends Component {
  8. @property(Node) btn_click:Node = null;
  9. private m_data:ui_att_item = null;
  10. private mCallBack = null;
  11. private mEventData:event_item_show_question_select_item = null;
  12. public initView(data:ui_att_item,event_data:event_item_show_question_select_item,index:number,call){
  13. this.mCallBack = call;
  14. this.mEventData = event_data;
  15. if(data===null){
  16. tools.showToast("配置问题选择错误!")
  17. }else{
  18. this.m_data = data;
  19. this.init()
  20. }
  21. }
  22. init(){
  23. gameManager.initUiBaseAtt(this.node,this.m_data)
  24. this.node.on(Node.EventType.TOUCH_END,()=>{
  25. if(this.mCallBack!=null){
  26. this.mCallBack(this.mEventData)
  27. }
  28. })
  29. }
  30. public getData(){
  31. return this.m_data;
  32. }
  33. }