From gdx-claude-skills
Use when writing libGDX Java/Kotlin code involving audio (Sound, Music, Gdx.audio). Use when debugging audio not playing, audio format issues, or platform-specific audio behavior in libGDX.
How this skill is triggered — by the user, by Claude, or both
Slash command
/gdx-claude-skills:libgdx-audio-lifecycleThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Quick reference for libGDX audio APIs. Covers Sound, Music, platform gotchas, and common audio patterns.
Quick reference for libGDX audio APIs. Covers Sound, Music, platform gotchas, and common audio patterns.
| Sound | Music | |
|---|---|---|
| Loading | Fully into memory | Streamed from disk |
| Use for | Short effects (<1MB on Android) | Background tracks, long audio |
| Concurrent | Multiple instances via play() | One stream per Music object |
| Auto pause/resume | No | Yes (libGDX handles automatically) |
Formats: WAV, MP3, OGG all supported. OGG not supported on iOS — use WAV or MP3.
Sound snd = Gdx.audio.newSound(Gdx.files.internal("click.wav"));
// play() returns instance ID (long).
long id = snd.play(); // default volume
long id = snd.play(volume); // volume: [0, 1]
long id = snd.play(volume, pitch, pan); // pitch: [0.5, 2.0], pan: [-1, 1]
long id = snd.loop(); // same overloads as play()
long id = snd.loop(volume, pitch, pan);
// Per-instance control (pass the id from play/loop)
snd.setVolume(id, volume);
snd.setPitch(id, pitch);
snd.setPan(id, pan, volume); // NOTE: pan+volume together
snd.setLooping(id, true);
snd.stop(id);
snd.pause(id);
snd.resume(id);
// All-instance control (no id)
snd.stop();
snd.pause();
snd.resume();
snd.dispose(); // MUST call when done
In non-trivial projects, prefer loading audio via AssetManager rather than raw Gdx.audio.newSound(). AssetManager handles disposal via unload() and supports async loading.
Gotchas:
play() on an already-playing Sound plays it concurrently (new instance).play() called in create() can silently fail on Android before the audio system is fully initialized. Defer initial sound playback to the first render() frame or use a boolean flag.Music bgm = Gdx.audio.newMusic(Gdx.files.internal("theme.ogg")); // OGG not supported on iOS — use MP3 for cross-platform
bgm.play();
bgm.pause();
bgm.stop(); // resets to beginning
bgm.setVolume(volume); // [0, 1]
float v = bgm.getVolume();
bgm.setPan(pan, volume); // [-1, 1], [0, 1]
bgm.setLooping(true);
boolean playing = bgm.isPlaying();
boolean looping = bgm.isLooping();
bgm.setPosition(seconds); // seek (float, in seconds)
float pos = bgm.getPosition();
bgm.setOnCompletionListener(music -> {
// Called when music finishes playing
});
bgm.dispose(); // MUST call when done
In non-trivial projects, prefer loading audio via AssetManager rather than raw Gdx.audio.newMusic(). AssetManager handles disposal via unload() and supports async loading.
Gotchas:
ApplicationListener.pause(). Doing so is redundant.setPosition() is unreliable on some Android devices for MP3 — seeking uses bitrate estimation and can be off by several seconds. OGG seeking is more accurate, but OGG is unsupported on iOS. For cross-platform seeking accuracy, consider WAV (large files) or accept MP3 imprecision.Store Music in the Game class, not in individual Screens. Dispose only in Game.dispose().
public class MyGame extends Game {
public Music bgm;
@Override
public void create() {
bgm = Gdx.audio.newMusic(Gdx.files.internal("theme.mp3")); // use MP3 for iOS compatibility
bgm.setLooping(true);
bgm.play();
setScreen(new MenuScreen(this));
}
@Override
public void dispose() {
bgm.dispose();
getScreen().dispose();
}
}
| Behavior | Desktop (LWJGL3) | Android | iOS (RoboVM) |
|---|---|---|---|
| OGG support | Yes | Yes | No |
| Music auto-pause | On minimize only | Yes | Yes |
| Sound size limit | None | <1MB PCM | None |
| MP3 seeking accuracy | Good | Unreliable | Good |
render() frame.Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub kyu-n/gdx-claude-skills --plugin gdx-claude-skills