pub struct Sound {
pub name: String,
pub is_music: bool,
pub volume: f32,
pub pitch: f32,
pub looping: bool,
pub spatial_min_distance: f32,
pub spatial_max_distance: f32,
pub position: Option<Vec2>,
}Expand description
A loaded sound effect.
Fields§
§name: StringName identifier.
is_music: boolWhether this is a music track (streamed) vs SFX (loaded into memory).
volume: f32Base volume (0.0–1.0).
pitch: f32Pitch multiplier.
looping: boolWhether to loop.
spatial_min_distance: f32Minimum distance for spatial audio (within this, no attenuation).
spatial_max_distance: f32Maximum distance for spatial audio (beyond this, inaudible).
position: Option<Vec2>2D position for spatial audio.
Implementations§
Source§impl Sound
impl Sound
Sourcepub fn with_volume(self, volume: f32) -> Self
pub fn with_volume(self, volume: f32) -> Self
Builder: set volume.
Sourcepub fn with_pitch(self, pitch: f32) -> Self
pub fn with_pitch(self, pitch: f32) -> Self
Builder: set pitch.
Sourcepub fn with_looping(self, looping: bool) -> Self
pub fn with_looping(self, looping: bool) -> Self
Builder: set looping.
Sourcepub fn with_position(self, pos: Vec2) -> Self
pub fn with_position(self, pos: Vec2) -> Self
Builder: set 2D position for spatial audio.
Sourcepub fn with_spatial_range(self, min: f32, max: f32) -> Self
pub fn with_spatial_range(self, min: f32, max: f32) -> Self
Builder: set spatial distance range.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sound
impl RefUnwindSafe for Sound
impl Send for Sound
impl Sync for Sound
impl Unpin for Sound
impl UnsafeUnpin for Sound
impl UnwindSafe for Sound
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