Skip to content

Commit 0331f15

Browse files
Copilotjbampton
andauthored
Clean up Web Audio nodes after invader hit sound
Agent-Logs-Url: https://github.com/NextCommunity/NextCommunity.github.io/sessions/2e21a107-94cf-4f0c-8d3f-8dae8d66ef0b Co-authored-by: jbampton <418747+jbampton@users.noreply.github.com>
1 parent 8a25254 commit 0331f15

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/assets/js/games/space-invaders.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ const SpaceInvaders = (() => {
251251

252252
oscillator.connect(gainNode);
253253
gainNode.connect(_audioContext.destination);
254+
oscillator.onended = () => {
255+
oscillator.disconnect();
256+
gainNode.disconnect();
257+
};
254258

255259
oscillator.start(now);
256260
oscillator.stop(now + 0.1);

0 commit comments

Comments
 (0)