Pause.ts 825 B

1234567891011121314151617181920212223242526272829
  1. import { _decorator, director } from 'cc';
  2. import { ModulerBase } from '../../GameFrameWork/ModulerBase';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('Pause')
  5. export class Pause extends ModulerBase {
  6. protected onStart() {
  7. this.onBtnClick("_back", this._onBtnBack, this);
  8. this.onBtnClick("_continue", this._onContinue, this);
  9. this.onBtnClick("_btnPause", this._onPause, this)
  10. }
  11. private _onPause(){
  12. director.pause();
  13. this.getNode("_pause").active = true;
  14. }
  15. private _onBtnBack() {
  16. director.resume();
  17. this.getNode("_pause").active = false;
  18. director.preloadScene("StartScene");
  19. director.loadScene("StartScene");
  20. }
  21. private _onContinue(){
  22. this.getNode("_pause").active = false;
  23. director.resume();
  24. }
  25. }