removeSpriteConfig
Clear the sprite config recorded on a sound. After this, getSpriteConfig returns undefined for it.
removeSpriteConfig(id: string): void;
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | required | ID of the sound the sprites were set on. |
Returns
Nothing.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSound('game-sounds', '/audio/8-bit-game-sounds.mp3');
soundHub.setSoundSprite('game-sounds', { jump: [4.5, 5.5], fail: [6, 8.5] });
// Take the sprite sounds away first, while the keys can still be resolved
soundHub.removeSpriteSound('jump');
soundHub.removeSpriteSound('fail');
soundHub.removeSpriteConfig('game-sounds');
soundHub.getSpriteConfig('game-sounds'); // undefined
Good to know
- Only the record is cleared. The sprite sounds that
setSoundSpritecreated stay in the hub, soplaySprite('game-sounds', 'jump')still plays. - Afterwards
removeSpriteSoundcan no longer find those sprites by key. Pass the full sprite id instead, such as'game-sounds_jump', or remove the sprites before you clear the config, as in the example. - No event is dispatched. For an id that is not loaded, the error is logged, stored for
getLastErrorand dispatched as anerrorevent.
See also
removeSpriteSound: remove a sprite sound and its key.getSpriteConfig: read the config.soundSprite: overview of how sprites work.