Phaser Sound Studio - Main
Advanced audio management system for Phaser 3 games with sound effects and music control.
Sound Studio Main
Advanced audio management system for Phaser 3 games with sound effects and music control. This example demonstrates how to play sounds using the Phaser Sound Studio.
Features
- đĩ Sound Management: Centralized sound loading and playback
- đī¸ Channel System: Organize sounds by channels (HUD, SFX, Music, etc.)
- ⥠Performance: Optimized audio loading and caching
- đ§ Type Safety: Full TypeScript support with sound key validation
Live Example
Loading game...
Usage Example
import { getSoundStudio, PHASER_SOUND_STUDIO_KEY, PhaserSoundStudioPlugin, SoundListConfig } from 'phaser-sound-studio';
// Define sound keys and channels
const SOUND_KEYS = {
MOUSE_HOVER: 'mouse-hover',
MOUSE_CLICK: 'mouse-click',
} as const;
const SOUND_CHANNELS = {
HUD: 'hud',
BACKGROUND: 'background',
SFX: 'sfx',
MUSIC: 'music',
VOICE: 'voice'
} as const;
// Configure sounds
const soundKeys: SoundListConfig<SoundKeys, ChannelKeys> = {
[SOUND_KEYS.MOUSE_HOVER]: {
channel: SOUND_CHANNELS.HUD,
preload: true,
path: '/sounds/ui-pop.m4a',
loop: false,
},
[SOUND_KEYS.MOUSE_CLICK]: {
channel: SOUND_CHANNELS.HUD,
preload: true,
path: '/sounds/click.mp3',
loop: false,
}
};
class GameScene extends Phaser.Scene {
preload(): void {
// Load all sounds
getSoundStudio(this).loadAll(this);
}
create(): void {
// Play sounds
getSoundStudio<SoundKeys, ChannelKeys>(this).play(this, SOUND_KEYS.MOUSE_CLICK);
}
} Configuration
Sound Configuration
- âĸ
channel- Audio channel for organization - âĸ
preload- Whether to preload the sound - âĸ
path- Path to the sound file - âĸ
loop- Whether the sound should loop
Channels
- âĸ
HUD- UI sound effects - âĸ
SFX- Game sound effects - âĸ
MUSIC- Background music - âĸ
VOICE- Voice/dialogue audio