diff --git a/assets/Script/module/Config/GameConfig.ts b/assets/Script/module/Config/GameConfig.ts index 8fb0b21d..512c102b 100644 --- a/assets/Script/module/Config/GameConfig.ts +++ b/assets/Script/module/Config/GameConfig.ts @@ -289,7 +289,7 @@ export class GameConfig { ready && this.BLOCK_INFO[0] === blockInfo && this.LEVEL_INFO[0] === levelInfo); } - /** JSON 和图片准备共用现有 Loading;失效请求不能关闭后续请求的 Loading。 */ + /** 已有转场承载资源等待时不叠加 Loading;失效请求不能关闭后续请求的 Loading。 */ static createBlockLoading(isCurrent: () => boolean): { open: () => void; close: () => void } { if (this.cancelBlockLoading) this.cancelBlockLoading(); const scene = cc.director.getScene(); @@ -308,6 +308,8 @@ export class GameConfig { open: () => { if (!closed && !opened && isCurrent() && cc.director.getScene() === scene && controller && cc.isValid(controller, true)) { + const transition = canvas.getChildByName("zhuanchang"); + if (transition && transition.activeInHierarchy) return; opened = true; controller.openLoad(); } diff --git a/docs/level-resources.md b/docs/level-resources.md index 5ac4d1c9..6f472323 100644 --- a/docs/level-resources.md +++ b/docs/level-resources.md @@ -55,7 +55,7 @@ node packages/level-resources/pack.js --rollback build/wechatgame-levels/levels/ 每次开局读取自己的JSON对象,后台落盘不会替换进行中的棋盘。独立下载的单关文件先校验大小/hash/结构,再原子安装和更新索引;失败保留旧版本。缓存文件损坏不能当作可用旧资源。 -首页开局和连续通关在读取JSON前立即打开现有Loading,JSON和图片准备完成后沿用原转场进入GameScene,不新增固定动画等待,也不串行化已有场景预加载。有效本地资源仍允许离线开局;没有可用本地资源时,前台读取最多等待60秒(包含manifest、下载排队、下载及安装后读取)。已检测到离线或等待中断网立即失败,请求明确失败也可提前结束,不必等满60秒;底层单次网络请求保留原有超时。 +首页开局和连续通关优先使用已显示的转场承载JSON和图片准备等待,不叠加Loading动画;只有没有可见转场时才打开现有Loading。资源准备完成后沿用原流程进入GameScene,不新增固定动画等待,也不串行化已有场景预加载。有效本地资源仍允许离线开局;没有可用本地资源时,前台读取最多等待60秒(包含manifest、下载排队、下载及安装后读取)。已检测到离线或等待中断网立即失败,请求明确失败也可提前结束,不必等满60秒;底层单次网络请求保留原有超时。 关卡读取失败通过wx.showModal显示“关卡读取失败,请连接网络!”,只显示“确定”。弹窗出现即作废本次开局回调,确认后返回HomeScene;原本就在首页则关闭Loading/转场并恢复开始按钮。断网下再次点击会再次提示;联网后点击会重新准备关卡,资源就绪才进入GameScene。后台预下载保持离线暂停和联网恢复,迟到下载可缓存,但不能自动恢复已取消的开局。登录8秒放行和无限模式总包准备规则保持原样。 diff --git a/tools/test-first-game-entry.cjs b/tools/test-first-game-entry.cjs index 50ddb52b..b26c25c9 100644 --- a/tools/test-first-game-entry.cjs +++ b/tools/test-first-game-entry.cjs @@ -31,7 +31,7 @@ function deferred() { } function fixture() { - const state = { scene: { name: 'HomeScene' }, eligible: true, events: [], timers: [], errors: [], preloads: [], holds: 0, + const state = { scene: { name: 'HomeScene' }, transition: { activeInHierarchy: false }, eligible: true, events: [], timers: [], errors: [], preloads: [], holds: 0, downloads: deferred(), blocks: deferred(), bundleCallbacks: [], jsonCallbacks: [], logs: [] }; const controller = { openLoad() { state.loading = true; }, @@ -40,7 +40,7 @@ function fixture() { }; const cc = { warn() {}, isValid: value => !!value && !value.destroyed, fx: {}, - find: () => ({ getComponent: () => controller }), + find: () => ({ getComponent: () => controller, getChildByName: name => name === 'zhuanchang' ? state.transition : null }), sys: { platform: 'web', WECHAT_GAME: 'wechat' }, assetManager: { loadBundle(name, options, done) { assert.equal(options.priority, 10); state.bundleCallbacks.push(done); }, loadAny(request, options, done) { @@ -129,6 +129,26 @@ test('entry waits for the difficulty table and retries a failed load before star }); for (const sceneName of ['HomeScene', 'GameScene']) { + test(`active transition carries JSON and image waiting without a loading overlay from ${sceneName}`, async () => { + const { Config, state } = fixture(); + state.scene.name = sceneName; state.transition.activeInHierarchy = true; + Config.firstGameplayEntryComplete = true; + const json = deferred(); + Config.loadLevelResource = () => json.promise; + Config.applyLevelData = () => Config.enterGameSceneWhenReady(0); + Config.prepareBlockWindow = onRemoteRequired => { onRemoteRequired(); return state.blocks.promise; }; + Config.LEVEL_INFO_init(true, 0, false); + assert.notEqual(state.loading, true); + assert.equal(state.events.includes('loadScene'), false); + json.resolve({}); await flush(); + assert.notEqual(state.loading, true, 'image preparation must not re-open Loading over the transition'); + assert.equal(state.events.includes('loadScene'), false); + await resourcesReady(state); + assert.equal(state.timers[0].delay, 0, 'no extra animation wait'); + state.timers[0].done(); + assert.equal(state.events.includes('loadScene'), true); + }); + test(`loading is visible before JSON resolves on later entry from ${sceneName}`, async () => { const { Config, state } = fixture(); state.scene.name = sceneName; Config.firstGameplayEntryComplete = true;