Commit b22b12fb authored by liujiangnan's avatar liujiangnan

feat: 预加载资源

parent 7a1ac669
...@@ -160,8 +160,26 @@ OP26.data_mgr = { ...@@ -160,8 +160,26 @@ OP26.data_mgr = {
console.log("数据处理完毕:"); console.log("数据处理完毕:");
}, },
type: function (v) {
return Object.prototype.toString.call(v);
},
getUrls: function (obj) {
let arr = [];
for (const key in obj) {
const val = obj[key];
if (this.type(val) === '[object Object]' || this.type(val) === '[object Array]') {
arr = arr.concat(this.getUrls(val));
} else if (this.type(val) === '[object String]' && val.indexOf("http")>-1) {
arr.push({url: val});
}
}
return arr;
},
preload() { preload() {
cc.assetManager.loadAny(null, null, null, (err, data) => { const urls = this.getUrls(this.data);
cc.assetManager.loadAny(urls, null, null, (err, data) => {
if (window && window["air"]) { if (window && window["air"]) {
cc.find('Canvas').opacity = 0; cc.find('Canvas').opacity = 0;
window.air.onCourseInScreen = (next) => { window.air.onCourseInScreen = (next) => {
......
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