logic.ts 834 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. export class GameLogicMgr {
  2. private static _inst: GameLogicMgr;
  3. public static get inst(): GameLogicMgr {
  4. if (this._inst == null) {
  5. this._inst = new GameLogicMgr();
  6. this._inst.init();
  7. }
  8. return this._inst;
  9. }
  10. isGamePause: boolean = false;
  11. switch(){
  12. this.isGamePause = !this.isGamePause;
  13. //@ts-ignore
  14. dragonBones.timeScale = this.isGamePause ? 0 : 1;
  15. }
  16. init(){
  17. //@ts-ignore
  18. let aniMgr = cc.director.getAnimationManager();
  19. if(!CC_EDITOR){
  20. aniMgr._oldUpdate = aniMgr.update;
  21. aniMgr.update = function(dt){
  22. if(GameLogicMgr.inst.isGamePause) return;
  23. aniMgr._oldUpdate(dt);
  24. }
  25. }
  26. }
  27. };