Sound
Sounds are WAV, OGG or MP3 files in the project. The sound name is the file name, without the extension.
Audio.play("tiro", { volume = 0.4 })
local motor = Audio.play("motor", { loop = true })Audio.stop(motor)
Audio.playMusic("tema", 0.6)Audio::play("tiro", {.volume = 0.4f});
SoundId motor = Audio::play("motor", {.loop = true});Audio::stop(motor);
Audio::playMusic("tema", 0.6f);Effects
Section titled “Effects”| Function | What it does |
|---|---|
Audio.play(sound, opcoes) |
Plays a sound and returns its id (0 if the sound does not exist). Options: volume (0 to 1, default 1) and loop (default false). |
Audio.stop(id) |
Stops a playing sound. |
Audio.stopAll() |
Stops all sounds. |
Music is streamed from the file. Only one plays at a time: playing another replaces the current one.
| Function | What it does |
|---|---|
Audio.playMusic(sound, volume) |
Plays the music, looping. Returns false if the sound does not exist. |
Audio.stopMusic() |
Stops the music. |
Audio.setMusicVolume(volume) |
Changes the music volume, from 0 to 1. |
Audio.musicPlaying() |
true if music is playing. |
- Several effects can play at the same time.
- Use WAV for short effects and OGG or MP3 for music.
- In C++ the functions are under
Audio::. The Copy code button, in the sound Inspector, copies the ready line.
