useAudiofunctionhooknacatamalon
useAudio() => TAudioHandleThe game's volumes: the general one and one per channel, plus a way to silence everything.
A channel is a group of sounds that share a volume. 'sfx' and 'music' are there from the
start, and any other name works the moment a sound uses it. This is what the sliders of an
options screen move, and the numbers a game saves in its store so they are still there next time.
Volumes go from 0 (silent) to 1 (as recorded); above 1 is allowed and can distort.
Example
declare const settings: TGameStore<{ music: number }>;
declare const quieter: TText;
export const Options: TSceneFn = () => {
const audio = useAudio();
audio.setVolume(settings.state.music, 'music');
listen(quieter, { onClick: () => audio.setVolume(audio.getVolume('music') - 0.1, 'music') });
return createScene();
};