back_title.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { _decorator, Component, Label, Node, Vec3 } from 'cc';
  2. import { gameManager } from '../gameManager';
  3. import { SdkUtil } from '../../sdkUtil';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('back_title')
  6. export class back_title extends Component {
  7. @property(Node) btn_back:Node = null;
  8. @property(Node) img_title_bg:Node = null;
  9. @property(Node) img_title:Node = null;
  10. private mCallBack = null;
  11. protected start(): void {
  12. if(SdkUtil.iPhoneIsLingdongdao()&&SdkUtil.KS_GAME==false) {
  13. let p = this.img_title_bg.getPosition()
  14. this.img_title_bg.setPosition(p.x,p.y-60,p.z)
  15. }
  16. }
  17. public initView(title:string,call_back){
  18. this.mCallBack = call_back;
  19. this.updateTitle(title)
  20. this.btn_back.off(Node.EventType.TOUCH_END)
  21. this.btn_back.on(Node.EventType.TOUCH_END,()=>{
  22. if(this.mCallBack!=null){
  23. this.mCallBack()
  24. }
  25. gameManager.Singleton.sys_click_button_music()
  26. })
  27. }
  28. public updateTitle(title:string){
  29. if(title.length<=0){
  30. this.img_title.parent.active = false;
  31. }else{
  32. this.img_title.parent.active = true;
  33. }
  34. this.img_title.getComponent(Label).string = title;
  35. }
  36. }