pub struct AudioManager { /* private fields */ }
Expand description
You will interact with the AudioManager
for all audio needs in Rusty Engine. It is exposed
through the Engine
struct provided to your logic function
each frame as the audio_manager
field. It is also
accessible through the Game
struct in your main
function.
Implementations§
Source§impl AudioManager
impl AudioManager
Sourcepub fn play_sfx<S: Into<String>>(&mut self, sfx: S, volume: f32)
pub fn play_sfx<S: Into<String>>(&mut self, sfx: S, volume: f32)
Play a sound effect. volume
ranges from 0.0
to 1.0
. sfx
can be an SfxPreset
or a
string containing the relative path/filename of a sound file within the assets/
directory. Sound effects are “fire and forget”. They will play to completion and then stop.
Multiple sound effects will be mixed and play simultaneously.
Sourcepub fn play_music<S: Into<String>>(&mut self, music: S, volume: f32)
pub fn play_music<S: Into<String>>(&mut self, music: S, volume: f32)
Play looping music. volume
ranges from 0.0
to 1.0
. Music will loop until stopped with
stop_music
. Playing music stops any previously playing music.
music
can be a MusicPreset
or a string containing the relative path/filename of a
sound file within the assets/
directory.
Sourcepub fn stop_music(&mut self)
pub fn stop_music(&mut self)
Stop any music currently playing. Ignored if no music is currently playing.
Sourcepub fn music_playing(&self) -> bool
pub fn music_playing(&self) -> bool
Whether music is currently playing.
Trait Implementations§
Source§impl Debug for AudioManager
impl Debug for AudioManager
Source§impl Default for AudioManager
impl Default for AudioManager
Source§fn default() -> AudioManager
fn default() -> AudioManager
Auto Trait Implementations§
impl Freeze for AudioManager
impl RefUnwindSafe for AudioManager
impl Send for AudioManager
impl Sync for AudioManager
impl Unpin for AudioManager
impl UnwindSafe for AudioManager
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World
.