back_title.ts 971 B

1234567891011121314151617181920212223242526272829303132
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. import { gameManager } from '../gameManager';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('back_title')
  5. export class back_title extends Component {
  6. @property(Node) btn_back:Node = null;
  7. @property(Node) img_title:Node = null;
  8. private mCallBack = null;
  9. public initView(title:string,call_back){
  10. this.mCallBack = call_back;
  11. this.updateTitle(title)
  12. this.btn_back.off(Node.EventType.TOUCH_END)
  13. this.btn_back.on(Node.EventType.TOUCH_END,()=>{
  14. if(this.mCallBack!=null){
  15. this.mCallBack()
  16. }
  17. gameManager.Singleton.sys_click_button_music()
  18. })
  19. }
  20. public updateTitle(title:string){
  21. if(title.length<=0){
  22. this.img_title.parent.active = false;
  23. }else{
  24. this.img_title.parent.active = true;
  25. }
  26. this.img_title.getComponent(Label).string = title;
  27. }
  28. }