Pause.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { _decorator, director, PhysicsSystem2D } from 'cc';
  2. import { ModulerBase } from '../../GameFrameWork/ModulerBase';
  3. import { GameInfo } from '../../../GameInfo';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('Pause')
  6. export class Pause extends ModulerBase {
  7. protected onStart() {
  8. this.onBtnClick("_back", this._onBtnBack, this);
  9. this.onBtnClick("_continue", this._onContinue, this);
  10. this.onBtnClick("_btnPause", this._onPause, this)
  11. }
  12. //暂停
  13. private _onPause() {
  14. GameInfo.Instance.setIsGameOver(true);
  15. director.pause();
  16. this.getNode("_pause").active = true;
  17. }
  18. //返回开始场景
  19. private _onBtnBack() {
  20. this.getNode("_pause").active = false;
  21. director.loadScene("StartScene", () => {
  22. director.resume();
  23. GameInfo.Instance.setIsGameOver(false);
  24. });
  25. }
  26. //继续游戏
  27. private _onContinue() {
  28. this.getNode("_pause").active = false;
  29. director.resume();
  30. GameInfo.Instance.setIsGameOver(false)
  31. }
  32. }