Commit 6ac4dd24 authored by liujiangnan's avatar liujiangnan

feat: 预加载

parent 13402734
...@@ -153,6 +153,9 @@ export default class NewClass extends middleLayerBase { ...@@ -153,6 +153,9 @@ export default class NewClass extends middleLayerBase {
this.preloadCount += data.rows.length; this.preloadCount += data.rows.length;
} }
this.log('data.rows = ' + JSON.stringify(data.rows)); this.log('data.rows = ' + JSON.stringify(data.rows));
// const arr = data.rows.filter(item => item.sceneName ==='l2_boardgame2_tree');
// const arr1 = data.rows.filter(item => item.sceneName ==='BoardGame2');
// const resArr = [...arr, ...arr1];
this.batchPreloadScene(data.rows); this.batchPreloadScene(data.rows);
}); });
} }
...@@ -179,28 +182,14 @@ export default class NewClass extends middleLayerBase { ...@@ -179,28 +182,14 @@ export default class NewClass extends middleLayerBase {
} }
cc.assetManager.loadBundle(scene.bondleUrl, { version: scene.version }, (err, bundle) => { cc.assetManager.loadBundle(scene.bondleUrl, { version: scene.version }, (err, bundle) => {
console.log(`${scene.bondleUrl}---场景开始loadBundle----`); console.log(`${scene.bondleUrl}---场景开始loadBundle----`);
if (!bundle) { _this.loadedCount++;
_this.loadedCount++; _this.updateProcessBar();
_this.updateProcessBar(); i++;
i++; if (i < scenes.length) {
if (i < scenes.length) { setTimeout(() => {
setTimeout(() => { load();
load(); }, 1);
}, 1);
}
return;
} }
bundle.preloadScene(scene.sceneName, () => { }, () => {
console.log(`${scene.sceneName}场景预加载结束`);
_this.loadedCount++;
_this.updateProcessBar();
i++;
if (i < scenes.length) {
setTimeout(() => {
load();
}, 1);
}
});
}); });
} }
......
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