diff --git a/single-html/loader-and-starter.js b/single-html/loader-and-starter.js index a39a0cf..f7bb3f6 100644 --- a/single-html/loader-and-starter.js +++ b/single-html/loader-and-starter.js @@ -18,6 +18,8 @@ window.unmuteAudio = function() { cc.audioEngine.resumeAll() } +window.registerLoad = false; + console.log("entry file loaded") function b64ToUint6(nChr) { @@ -69,7 +71,11 @@ function loadJson(item, _, callback) { var assetMap = window.assetMap; -setTimeout(() => { +var registerInterval = setInterval(() => { + if (window.cc == undefined) { + return; + } + clearInterval(registerInterval); cc.assetManager.downloader.register({ "bundle": function (item, _, callback) { var bundleJsKey = Object.keys(assetMap).find(key => key.includes(item + "/index") && key.endsWith(".js")) @@ -79,12 +85,12 @@ setTimeout(() => { loadJs(bundleJsKey, _, (a1, data) => { console.log("bundle js loaded:", bundleJsKey) }) - + var bundleJsonKey = Object.keys(assetMap).find(key => key.includes(item + "/config") && key.endsWith(".json")) if (!bundleJsonKey) { console.error(`bundle ${item} not found`) } - loadJson(bundleJsonKey, _, (a1, data) => + loadJson(bundleJsonKey, _, (a1, data) => { var completeData = data; completeData.base = "assets/" + item + "/" @@ -126,7 +132,8 @@ setTimeout(() => { ) }, }) -}, 10); + window.registerLoad = true; +}, 16); window.base122ToArrayBuffer = (e) => { const n = [0, 10, 13, 34, 38, 92], r = new Uint8Array(1.75 * e.length | 0); let t = 0, o = 0, f = 0; function s(e) { o |= (e <<= 1) >>> f, f += 7, f >= 8 && (r[t++] = o, f -= 8, o = e << 7 - f & 255) } for (let r = 0; r < e.length; r++) { const t = e.charCodeAt(r); if (t > 127) { const e = t >>> 8 & 7; 7 !== e && s(n[e]), s(127 & t) } else s(t) } return new Uint8Array(r.buffer, 0, t) }