MyApp.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import { _decorator, Component, Node } from 'cc';
  2. import { UIMgr } from '../Frames/UIManager';
  3. import { resMgr } from '../Frames/ResourcesMgr';
  4. import { dataMgr } from '../Frames/DataManager';
  5. import { UIType } from './GameFrameWork/UIBase';
  6. import { LoadingUI } from './UI/LoadingUI';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('MyApp')
  9. export class MyApp extends Component {
  10. protected async onLoad(){
  11. await UIMgr.openUI("LoadingUI",UIType.PAGE);
  12. const loadingUI = UIMgr.getUI(LoadingUI);
  13. await resMgr.loadAllRes("Res", (finish, total)=>{
  14. if(loadingUI){
  15. loadingUI.updateProgress(finish / total);
  16. loadingUI.updateWhichRes(1);
  17. }
  18. });
  19. await resMgr.loadAllRes("UI", (finish, total)=>{
  20. if(loadingUI){
  21. loadingUI.updateProgress(finish / total);
  22. loadingUI.updateWhichRes(2);
  23. }
  24. });
  25. await dataMgr.loadDataDir("Data");
  26. UIMgr.closeUI("LoadingUI");
  27. UIMgr.openUI("Start",UIType.PAGE);
  28. }
  29. }