Play sounds
You want to play a sound effect when something happens.
- Drag the
.wavfile into the Recursos (Resources) panel. The name of the sound is the name of the file without the.wav. - In the code, play it by name:
Audio::play("explosao");How it works
Section titled “How it works”Audio::play(name)starts playing the sound and returns right away: the game doesn’t stop to wait.- Several sounds can play at the same time.
- For now, Brasa plays WAV files.
Variations
Section titled “Variations”Volume (from 0 to 1):
Audio::play("tiro", {.volume = 0.4f});Looping music, stopping it later:
// in the class: SoundId music_ = 0;music_ = Audio::play("musica", {.volume = 0.6f, .loop = true});// ... later:Audio::stop(music_);Audio::stopAll() stops all the sounds.
