Skip to content
Snippets Groups Projects
Verified Commit b6ba0f2c authored by Louis's avatar Louis :fire:
Browse files

Add a new function for getting the handle of a looped sfx track

parent dd6d1c5f
No related branches found
No related tags found
No related merge requests found
...@@ -263,6 +263,25 @@ impl<'w, 's, T: SuppliesAudio> MusicBox<'w, 's, T> { ...@@ -263,6 +263,25 @@ impl<'w, 's, T: SuppliesAudio> MusicBox<'w, 's, T> {
TrackType::Missing => None, TrackType::Missing => None,
} }
} }
/// Play a new sound effect on the SFX channel in a loop. Ideal for ambient spatial sounds
/// like a crackling fireplace
///
/// # Returns
///
/// A handle for the newly started audio instance, or `None` if the track was not found
pub fn start_looped_sfx<Name: ToString>(
&mut self,
name: Name,
) -> Option<Handle<AudioInstance>> {
match self.map_tracks(name) {
TrackType::WithIntro(_, track) | TrackType::Single(track) => {
let instance = self.channels.sfx_channel.play(track).looped().handle();
Some(instance)
}
TrackType::Missing => None,
}
}
/// Play a new sound effect on the UI SFX channel /// Play a new sound effect on the UI SFX channel
/// ///
/// # Returns /// # Returns
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment