new AudioManager()
An audio manager. Controlls multiple sounds at once. Screen objects come with an AudioManager (Screen.audio), but you can create your own for more fine-grained control. This allows you to easily control the volume of different parts of your game independently, i.e. seperate SFX, menu, and gameplay sound sliders.
import { gameify } from "./gameify/gameify.js"
const myAudioManager = new gameify.audio.AudioManager();
const mySound = new gameify.audio.Sound("my-sound.mp3");
myAudioManager.add(mySound);Members
(readonly) sounds
Sounds this AudioManager controlls. Don't modify this - Use add() and remove() to add/remove sounds. AudioManagers are set to 20% volume by default, to protect your ears.
Methods
add(sound)
Add a sound to the AudioManager
| Name | Type | Description |
|---|---|---|
sound | gameify. | The sound to add |
getVolume() → {Number}
Get the volume of the AudioManager. Note that this volume is mixed with the volume of each sound. Use Sound.getCalculatedVolume to get the actual volume of each sound.
- Type:
- Number
setVolume(volume)
Adjust the volume of all controlled sounds
| Name | Type | Description |
|---|---|---|
volume | Number | The volume modifier, from 0 to 1 |