Expand description
Facilities for interacting with audio, including: AudioManager
, MusicPreset
, and
SfxPreset
You may add your own sound files to the assets/
directory or any of its subdirectories
and play them as sound effects or music by providing the relative path to the file. For example,
if you place a file named my_sound_effect.mp3
in assets/
, you can play it with:
// Inside your logic function...
game.audio_manager.play_sfx("my_sound_effect.mp3", 1.0);
Or, if you create a assets/my_game/
subdirectory and place a file named spooky_loop.ogg
, you
could play it as continuous music with:
// Inside your logic function...
game.audio_manager.play_music("my_game/spooky_loop.ogg", 1.0);
The sound effects provided in this asset pack have convenient enum
s defined that you can use
instead of a path to the file: SfxPreset
and MusicPreset
. For example:
// Import the enums into scope first
use rusty_engine::prelude::*;
// Inside your logic function...
game.audio_manager.play_sfx(SfxPreset::Confirmation1, 1.0);
game.audio_manager.play_music(MusicPreset::Classy8Bit, 1.0);
Structs§
- Audio
Manager - You will interact with the
AudioManager
for all audio needs in Rusty Engine. It is exposed through theEngine
struct provided to your logic function each frame as theaudio_manager
field. It is also accessible through theGame
struct in yourmain
function. - Music
Enums§
- Music
Preset - Music included with the downloadable asset pack. You can hear this music in the
music
example by cloning therusty_engine
repository and running the following command: - SfxPreset
- Sound effects included with the downloadable asset pack. You can hear these all played in the
sfx
example by cloning therusty_engine
repository and running the following command: