logic.ts 926 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. }
  14. init(){
  15. //@ts-ignore
  16. let aniMgr = cc.director.getAnimationManager();
  17. aniMgr._oldUpdate = aniMgr.update;
  18. aniMgr.update = function(dt){
  19. if(GameLogicMgr.inst.isGamePause) return;
  20. aniMgr._oldUpdate(dt);
  21. }
  22. }
  23. }
  24. export class GameLogic extends cc.Component {
  25. logicId:number;
  26. update(dt: number): void {
  27. if(GameLogicMgr.inst.isGamePause) return;
  28. this.gameUpdate(dt);
  29. }
  30. gameUpdate(dt:number): void {
  31. };
  32. }