levelMgr.ts 793 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { ResMgr } from "./resMgr";
  2. let pass = 3;
  3. /**
  4. * 1 切换关卡
  5. */
  6. export class LevelMgr {
  7. parent: cc.Node;
  8. title: cc.Label;
  9. passCnt: number = 0;
  10. private static _inst: LevelMgr;
  11. public static get inst(): LevelMgr {
  12. if (this._inst == null) {
  13. this._inst = new LevelMgr();
  14. }
  15. return this._inst;
  16. }
  17. begin(){
  18. this.passCnt = 0;
  19. this.load();
  20. }
  21. next(){
  22. this.passCnt ++;
  23. if(this.passCnt >= pass) return;
  24. this.load();
  25. }
  26. private load() {
  27. this.title.string = `level${this.passCnt + 1}`;
  28. this.parent.destroyAllChildren();
  29. ResMgr.inst.loadPrefab(`level/level${this.passCnt + 1}`, this.parent);
  30. }
  31. }