PauseUI.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. }
  15. /**
  16. * 按钮点击事件
  17. * @param event 事件
  18. * @param param 参数
  19. */
  20. override onBtnClicked(event:EventTouch, customEventData:any) {
  21. super.onBtnClicked(event,customEventData);
  22. let btnName = event.target.name;
  23. if(btnName === 'back_main_btn'){//返回首页
  24. Game.I.isGameOver = true;
  25. uiMgr.pop(Constants.mainUIs.main);
  26. }else if(btnName === 'continue_btn'){
  27. uiMgr.hide(Constants.popUIs.pauseUI,()=>{
  28. Game.I.isPause = false;
  29. });
  30. }
  31. }
  32. }