diff --git a/docs/getting-started/publish-to-github-pages.md b/docs/getting-started/publish-to-github-pages.md index df969d7..87d2f0f 100644 --- a/docs/getting-started/publish-to-github-pages.md +++ b/docs/getting-started/publish-to-github-pages.md @@ -69,6 +69,7 @@ Open the GitHub Pages URL and confirm: - controls or motion behave the same way they did locally If the page exists but shows stale content, give GitHub Pages a short time to finish deployment and refresh again. +If you're using Chrome, you may need to do a hard refresh to get the game to update: hold down the CTRL key and click the refresh button to the left of the address bar. ## Common Failure Modes diff --git a/src/runtime/main.ts b/src/runtime/main.ts index 07a8f07..4987cbb 100644 --- a/src/runtime/main.ts +++ b/src/runtime/main.ts @@ -31,6 +31,13 @@ export function createGameConfig(container: string): Phaser.Types.Core.GameConfi }; } +export function configureGameAudioPersistence(game: Phaser.Game): void +{ + const soundManager = (game as any)?.sound; + if (!soundManager) return; + soundManager.pauseOnBlur = false; +} + export default function StartGame(container: string): Phaser.Game { const config = createGameConfig(container); @@ -43,6 +50,7 @@ export default function StartGame(container: string): Phaser.Game } const game = new Phaser.Game(config); + configureGameAudioPersistence(game); (window as any).__phaserGame = game; return game; } diff --git a/tests/runtime/main.test.ts b/tests/runtime/main.test.ts new file mode 100644 index 0000000..8e0593f --- /dev/null +++ b/tests/runtime/main.test.ts @@ -0,0 +1,21 @@ +// @vitest-environment jsdom +import { describe, expect, it } from 'vitest'; +import { configureGameAudioPersistence } from '../../src/runtime/main'; + +describe('runtime game bootstrap', () => { + it('disables Phaser pause-on-blur so published audio keeps playing across focus changes', () => { + const game = { + sound: { + pauseOnBlur: true, + }, + } as any; + + configureGameAudioPersistence(game); + + expect(game.sound.pauseOnBlur).toBe(false); + }); + + it('tolerates game instances without a sound manager', () => { + expect(() => configureGameAudioPersistence({} as any)).not.toThrow(); + }); +});