Audio
Audio Setup
Follow these simple steps to integrate sound into your Turbo game:
- Create an
audio
Folder
- Inside your project directory, create a folder named
audio
. This folder will contain all your sound files.
- Put Images in the Folder
- The following file formats are supported:
.wav
,.mp3
,.ogg
, and.flac
Play Sound
Use audio::play(&str)
to play a sound effect from your audio folder. For example, if your sound effect is named "coin.wav" you can play it with audio:play("coin")
Looping sound
You can loop a sound like this:
if !audio::is_playing("background_music"){
audio::play("background_music");
}
This will automatically restart the music once it ends.