Commit 555e7f3b authored by liujiangnan's avatar liujiangnan

feat: 异步加载

parent fc142d9e
...@@ -20,17 +20,18 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -20,17 +20,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
onLoadEnd() { async onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考 // TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData(); this.initData();
this.initView(); this.initView();
this.initListener(); this.initListener();
} }
_cantouch = null;
initData() { initData() {
// 所有全局变量 默认都是null const middleLayer = cc.find('middleLayer');
this._cantouch = true; if (!middleLayer) {
cc.sys.localStorage.setItem('token', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywicGhvbmUiOiIxODUwMjEzOTQwNCIsInNpZ24iOiIxNzE1N2NjNS1kYTcyLTQ5N2QtYmY3OS1kY2NlYTViY2JiMjciLCJpYXQiOjE2NTI5NDc4MjQsImV4cCI6MTY1NTUzOTgyNH0.JCnCd7nPKaZNrEgUiGY8T-_9Evu8yHm89O6eLUVxvJs');
}
} }
initView() { initView() {
......
...@@ -87,7 +87,7 @@ export class MyCocosSceneComponent extends cc.Component { ...@@ -87,7 +87,7 @@ export class MyCocosSceneComponent extends cc.Component {
preload() { preload() {
const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList); const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList);
cc.assetManager.loadAny(preloadArr, null, null, (err, data) => { cc.assetManager.loadAny(preloadArr, null, null, async (err, data) => {
if (window && window["air"]) { if (window && window["air"]) {
// window["air"].onCourseInScreen = (next) => { // window["air"].onCourseInScreen = (next) => {
...@@ -95,10 +95,10 @@ export class MyCocosSceneComponent extends cc.Component { ...@@ -95,10 +95,10 @@ export class MyCocosSceneComponent extends cc.Component {
// this.onLoadEnd(); // this.onLoadEnd();
// next(); // next();
// }; // };
this.onLoadEnd(); await this.onLoadEnd();
window["air"].hideAirClassLoading(); window["air"].hideAirClassLoading();
} else { } else {
this.onLoadEnd(); await this.onLoadEnd();
} }
cc.debug.setDisplayStats(false); cc.debug.setDisplayStats(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment