logic.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. };
  28. export class GameLogic extends cc.Component {
  29. logicId:number;
  30. update(dt: number): void {
  31. if(GameLogicMgr.inst.isGamePause) return;
  32. this.gameUpdate(dt);
  33. }
  34. gameUpdate(dt:number): void {
  35. };
  36. }