PauseUI.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { _decorator, EventTouch} from 'cc';
  2. import { BaseExp } from '../core/base/BaseExp';
  3. import { uiMgr } from '../core/manager/UIManager';
  4. import { Constants } from '../data/Constants';
  5. import { Game } from '../game/Game';
  6. const { ccclass, property } = _decorator;
  7. //暂停游戏
  8. @ccclass('PauseUI')
  9. export class PauseUI extends BaseExp {
  10. public show(...args: any[]){
  11. this.hasAnim = true;
  12. this.closeOnBlank = false;
  13. Game.I.isPause = true;
  14. uiMgr.getPageComponent(Constants.mainUIs.main)?.playOrStopBGM(false);
  15. }
  16. /**
  17. * 按钮点击事件
  18. * @param event 事件
  19. * @param param 参数
  20. */
  21. override onBtnClicked(event:EventTouch, customEventData:any) {
  22. super.onBtnClicked(event,customEventData);
  23. let btnName = event.target.name;
  24. if(btnName === 'back_main_btn'){//返回首页
  25. Game.I.isGameOver = true;
  26. uiMgr.pop(Constants.mainUIs.main);
  27. }else if(btnName === 'continue_btn'){
  28. uiMgr.hide(Constants.popUIs.pauseUI,()=>{
  29. Game.I.isPause = false;
  30. uiMgr.getPageComponent(Constants.mainUIs.main)?.playOrStopBGM(true);
  31. });
  32. }
  33. }
  34. }