diff --git a/game.js b/game.js index 81191c8..f88eeed 100644 --- a/game.js +++ b/game.js @@ -126,6 +126,11 @@ const SFX = (() => { } document.addEventListener('touchstart', unlock, { once: true, passive: true }); document.addEventListener('pointerdown', unlock, { once: true, passive: true }); + document.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'visible' && ctx && ctx.state === 'suspended') { + ctx.resume(); + } + }); /* Core: play a tone with envelope */ function tone(freq, type, vol, attack, sustain, release, when) {