// Single audio file with multiple sounds
const audioSprite = this.sound.addAudioSprite('sfx');
// Play specific sound from sprite
audioSprite.play('jump');
audioSprite.play('coin');
audioSprite.play('explosion');
Why Essential: Reduce HTTP requests (one file vs 100). Faster loading. Mobile optimization. Easier asset management.
Pattern 6: Sound Pooling - Performance at Scale
// Create pool of reusable sound instances
const explosionPool = [];
const poolSize = 10;
for (let i = 0; i < poolSize; i++) {
explosionPool.push(this.sound.add('explosion', { volume: 0.7 }));
}
// Get available sound from pool
function playExplosion() {
const sound = explosionPool.find(s => !s.isPlaying);
if (sound) {
sound.play();
}
}
Why Essential: Mood transitions (explore → combat). Scene changes. Day/night cycles. Boss encounters.
Pattern 8: Web Audio API - Advanced Processing
Phaser provides access to the Web Audio API for advanced effects like reverb, filters, and distortion. Use this for environmental audio and special effects.
Pattern 9: Sound Configuration and Settings
Persistent audio settings with localStorage enable players to customize master volume, music volume, and SFX volume independently.
Pattern 10: Audio Feedback Patterns - The Impact Matrix
// Impact = Volume × Pitch × Timing
class AudioFeedback {
// Weak impact: low volume, high pitch, short
playHit() {
this.sound.play('hit', { volume: 0.3, rate: 1.2 });
}
// Medium impact: medium volume, normal pitch, medium
playExplosion() {
this.sound.play('explosion', { volume: 0.7, rate: 1.0 });
this.cameras.main.shake(100);
}
// HUGE impact: max volume, low pitch, long, with delay
playBossDefeat() {
this.time.delayedCall(100, () => {
this.sound.play('explosion-huge', {
volume: 1.0,
rate: 0.8, // Lower pitch = more powerful
detune: -200
});
this.cameras.main.shake(500, 0.01);
});
}
}
The Impact Formula:
Volume: Loudness = importance
Pitch: Low = powerful, high = weak/fast
Timing: Delay = weight, instant = snappy
Repetition: Rapid = intensity
The 50% Rule
Test this:
Play your game with sound
Rate the "feel" (1-10)
Mute the game
Rate the "feel" again
If the second score is more than 50% of the first, you haven't invested enough in audio. Great games lose half their impact when muted. That's the target.
Coming Up
In Part 8, we conclude with Lessons Learned - meta-analysis of this training journey. What patterns emerge across all systems? How do you go from tutorials to production games? What makes Phaser professional-grade?
Patterns documented: 459 total (Audio: 10, Previous: 449)
This is part of my daily developer log. Follow my journey as I learn new skills and build tools with Brian at Actyra.