phaserjs avatar

Audio And Sound

Handles everything audio in Phaser 4 games through the unified SoundManager API. You get WebAudio by default with HTML5 Audio fallback, covering playback, volume, looping, stereo panning, and spatial positioning. The fire-and-forget `this.sound.play()` is perfect for UI clicks and one-shots, while `this.sound.add()` gives you retained references for background music or interactive sounds you need to control. Audio sprites and markers let you pack multiple sounds into one file. Spatial audio works well for positional effects if you're on WebAudio. The manager auto-pauses on blur and handles mobile unlock requirements, which saves headaches. Good reference for the full sound lifecycle from preload to playback control.

skills.sh installs
1.1K
GitHub stars
40.7K
last updated
Aug 21, 2026

Install

$ npx -y skills add phaserjs/phaser --skill audio-and-sound --agent claude-code

Installs into .claude/skills of the current project.

Files

Audio and Sound

Phaser provides a unified Sound system via this.sound (a SoundManager) that abstracts over Web Audio API and HTML5 Audio. It handles loading, playback, volume, panning, looping, markers, audio sprites, spatial audio, and browser autoplay-policy unlocking.

Key source paths: src/sound/BaseSoundManager.js, src/sound/BaseSound.js, src/sound/webaudio/, src/sound/html5/, src/sound/SoundManagerCreator.js, src/sound/events/, src/sound/typedefs/ Related skills: ../loading-assets/SKILL.md, ../game-setup-and-config/SKILL.md

Quick Start

class GameScene extends Phaser.Scene {
    preload() {
        this.load.audio('bgm', 'assets/music.mp3');
        this.load.audio('coin', ['assets/coin.ogg', 'assets/coin.mp3']);
    }

    create() {
        // Fire-and-forget (auto-destroys when complete)
        this.sound.play('coin');

        // Retained reference for ongoing control
        this.music = this.sound.add('bgm', { loop: true, volume: 0.5 });
        this.music.play();
    }
}

Assets loaded via this.load.audio() in preload() are ready by the time create() runs. Provide an array of URLs for cross-browser format fallback.

Sponsors

Details

Repository
github.com/phaserjs/phaser
Categories
Backend & APIs, Game Development
First seen
Jun 3, 2026

More from phaserjs/phaser

All 8
1K-Dense-AI avatarpathogen-variant-surveillanceK-Dense-AI/scientific-agent-skillsQuery live pathogen genomic surveillance data through the GenSpectrum LAPIS API to find which viral lineages are circulating now, how fast they are growing, and1.1Kskills.sh installs
2mlflow avatarsearching-mlflow-docsmlflow/skillsSearches and retrieves MLflow documentation from the official docs site. Use when the user asks about MLflow features, APIs, integrations (LangGraph, LangChain,1.1Kskills.sh installs
3K-Dense-AI avatarpkpd-modelingK-Dense-AI/scientific-agent-skillsPharmacokinetic and pharmacodynamic modelling and simulation - non-compartmental analysis, compartmental and population PK, PK/PD and exposure-response, TMDD, P1.1Kskills.sh installs
4inference-sh avatarllm-modelsinference-sh/skillsAccess Claude, Gemini, Kimi, GLM and 100+ LLMs via inference.sh CLI using OpenRouter. Models: Claude Opus 4.5, Claude Sonnet 4.5, Claude Haiku 4.5, Gemini 3 Pro1.1Kskills.sh installs
5secondsky avatarplaywrightsecondsky/claude-skillsBrowser automation and E2E testing with Playwright. Auto-detects dev servers, writes clean test scripts. Test pages, fill forms, take screenshots, check respons1.1Kskills.sh installs
6orchestra-research avatarhuggingface-accelerateorchestra-research/ai-research-skillsSimplest distributed training API. 4 lines to add distributed support to any PyTorch script. Unified API for DeepSpeed/FSDP/Megatron/DDP. Automatic device place1Kskills.sh installs