pub struct SoundEffect { /* private fields */ }
Expand description
Sound effect (although it can also be used for music) You must call SoundEffect::update or SoundEffect::update_secs with accurate values and often otherwise playback may stutter or jump
§Usage
//this must live as long as `sound` but there's no lifetimes to enforce this
let mut engine = AudioEngine::new().unwrap();
let mut sound = engine.load_from_bytes(&BYTES, duration).unwrap();
sound.play();
loop {
timing.update();
sound.update(&timing);
}
Implementations§
Source§impl SoundEffect
impl SoundEffect
pub fn new(sound: Sound, duration: f64) -> SoundEffect
pub fn set_volume(&mut self, volume: f32)
Sourcepub fn can_play(&self) -> bool
pub fn can_play(&self) -> bool
Returns true if calling SoundEffect::play will do anything
Sourcepub fn update_secs(&mut self, delta: f64)
pub fn update_secs(&mut self, delta: f64)
Allows the sound to continue playing
Sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
If the sound is currently playing
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SoundEffect
impl RefUnwindSafe for SoundEffect
impl Send for SoundEffect
impl Sync for SoundEffect
impl Unpin for SoundEffect
impl UnwindSafe for SoundEffect
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.