this.bga.sounds
Sounds
For each sound you want to add, there should be an .ogg and an .mp3 with that file name in the sounds folder. See Game sounds: sounds directory for more details.
Preloading
By default, ALL sounds at the root of your sounds directory are loaded in a player's browser when they load the game. Avoid keeping unused sounds in your sounds directory, as they will slow down game loading. Sounds in a subfolder of sounds are NOT preloaded by default.
this.bga.sounds.dontPreloadSounds(sound_file_names: string[])
Using dontPreloadSounds, you tell the interface to not preload a specific sound in your sounds directory. Do not include the extension; the method automatically handles both filename.mp3 and filename.ogg.
Examples of use:
this.bga.sounds.preloadSounds(sound_file_names: string[])
Opposite of dontPreloadSounds, useful only for sounds that are not in the root sounds folder. Example of use:
// preload a particular sound
if (gamedatas.expansionActive) {
this.bga.sounds.preloadSounds(['expansion/extramove']);
}
this.bga.sounds.play(id: string): void Play a sound by its id (the filename without extension).
Examples :
this.bga.gameui.disableNextMoveSound(): void Disable the standard "move" sound for this move (to replace it with your custom sound):
Add this to your notification handler:
Note
It only disables the sound for the next move.