Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/getting-started/publish-to-github-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions src/runtime/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
21 changes: 21 additions & 0 deletions tests/runtime/main.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
Loading