AudioSource

Struct AudioSource 

Source
pub struct AudioSource { /* private fields */ }
Expand description

A class that represents an audio source node.

Implementations§

Source§

impl AudioSource

Source

pub fn set_volume(&mut self, val: f32)

Sets The volume of the audio source. The value is between 0.0 and 1.0.

Source

pub fn get_volume(&self) -> f32

Gets The volume of the audio source. The value is between 0.0 and 1.0.

Source

pub fn set_pan(&mut self, val: f32)

Sets The pan of the audio source. The value is between -1.0 and 1.0.

Source

pub fn get_pan(&self) -> f32

Gets The pan of the audio source. The value is between -1.0 and 1.0.

Source

pub fn set_looping(&mut self, val: bool)

Sets Whether the audio source is looping.

Source

pub fn is_looping(&self) -> bool

Gets Whether the audio source is looping.

Source

pub fn is_playing(&self) -> bool

Gets Whether the audio source is playing.

Source

pub fn seek(&mut self, start_time: f64)

Seeks the audio source to the given time.

§Arguments
  • startTime - The time to seek to.
Source

pub fn schedule_stop(&mut self, time_to_stop: f64)

Schedules the audio source to stop at the given time.

§Arguments
  • timeToStop - The time to wait before stopping the audio source.
Source

pub fn stop(&mut self, fade_time: f64)

Stops the audio source.

§Arguments
  • fadeTime - The time to fade out the audio source.
Source

pub fn play(&mut self) -> bool

Plays the audio source.

§Returns
  • bool - true if the audio source was played successfully, false otherwise.
Source

pub fn play_with_delay(&mut self, delay_time: f64) -> bool

Plays the audio source with a delay.

§Arguments
  • delayTime - The time to wait before playing the audio source.
§Returns
  • bool - true if the audio source was played successfully, false otherwise.
Source

pub fn play_background(&mut self) -> bool

Plays the audio source as a background audio.

§Returns
  • bool - true if the audio source was played successfully, false otherwise.
Source

pub fn play_3d(&mut self) -> bool

Plays the audio source as a 3D audio.

§Returns
  • bool - true if the audio source was played successfully, false otherwise.
Source

pub fn play_3d_with_delay(&mut self, delay_time: f64) -> bool

Plays the audio source as a 3D audio with a delay.

§Arguments
  • delayTime - The time to wait before playing the audio source.
§Returns
  • bool - true if the audio source was played successfully, false otherwise.
Source

pub fn set_protected(&mut self, value: bool)

Sets the protected state of the audio source.

§Arguments
  • value - The protected state.
Source

pub fn set_loop_point(&mut self, loop_start_time: f64)

Sets the loop point of the audio source.

§Arguments
  • loopStartTime - The time to start the loop.
Source

pub fn set_velocity(&mut self, vx: f32, vy: f32, vz: f32)

Sets the velocity of the audio source.

§Arguments
  • vx - The X coordinate of the velocity.
  • vy - The Y coordinate of the velocity.
  • vz - The Z coordinate of the velocity.
Source

pub fn set_min_max_distance(&mut self, min: f32, max: f32)

Sets the minimum and maximum distance of the audio source.

§Arguments
  • min - The minimum distance.
  • max - The maximum distance.
Source

pub fn set_attenuation(&mut self, model: AttenuationModel, factor: f32)

Sets the attenuation of the audio source.

§Arguments
  • model - The attenuation model.
  • factor - The factor of the attenuation.
Source

pub fn set_doppler_factor(&mut self, factor: f32)

Sets the Doppler factor of the audio source.

§Arguments
  • factor - The factor of the Doppler effect.
Source

pub fn new(filename: &str, auto_remove: bool) -> Option<AudioSource>

Creates a new audio source.

§Arguments
  • filename - The path to the audio file.
  • autoRemove - Whether to automatically remove the audio source when it is stopped.
§Returns
  • AudioSource - The created audio source node.
Source

pub fn with_bus( filename: &str, auto_remove: bool, bus: &AudioBus, ) -> Option<AudioSource>

Creates a new audio source.

§Arguments
  • filename - The path to the audio file.
  • autoRemove - Whether to automatically remove the audio source when it is stopped.
  • bus - The audio bus to use for the audio source.
§Returns
  • AudioSource - The created audio source node.

Trait Implementations§

Source§

impl Clone for AudioSource

Source§

fn clone(&self) -> AudioSource

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for AudioSource

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl INode for AudioSource

Source§

fn set_order(&mut self, val: i32)

Sets the order of the node in the parent’s children array.
Source§

fn get_order(&self) -> i32

Gets the order of the node in the parent’s children array.
Source§

fn set_angle(&mut self, val: f32)

Sets the rotation angle of the node in degrees.
Source§

fn get_angle(&self) -> f32

Gets the rotation angle of the node in degrees.
Source§

fn set_angle_x(&mut self, val: f32)

Sets the X-axis rotation angle of the node in degrees.
Source§

fn get_angle_x(&self) -> f32

Gets the X-axis rotation angle of the node in degrees.
Source§

fn set_angle_y(&mut self, val: f32)

Sets the Y-axis rotation angle of the node in degrees.
Source§

fn get_angle_y(&self) -> f32

Gets the Y-axis rotation angle of the node in degrees.
Source§

fn set_scale_x(&mut self, val: f32)

Sets the X-axis scale factor of the node.
Source§

fn get_scale_x(&self) -> f32

Gets the X-axis scale factor of the node.
Source§

fn set_scale_y(&mut self, val: f32)

Sets the Y-axis scale factor of the node.
Source§

fn get_scale_y(&self) -> f32

Gets the Y-axis scale factor of the node.
Source§

fn set_x(&mut self, val: f32)

Sets the X-axis position of the node.
Source§

fn get_x(&self) -> f32

Gets the X-axis position of the node.
Source§

fn set_y(&mut self, val: f32)

Sets the Y-axis position of the node.
Source§

fn get_y(&self) -> f32

Gets the Y-axis position of the node.
Source§

fn set_z(&mut self, val: f32)

Sets the Z-axis position of the node.
Source§

fn get_z(&self) -> f32

Gets the Z-axis position of the node.
Source§

fn set_position(&mut self, val: &Vec2)

Sets the position of the node as a Vec2 object.
Source§

fn get_position(&self) -> Vec2

Gets the position of the node as a Vec2 object.
Source§

fn set_skew_x(&mut self, val: f32)

Sets the X-axis skew angle of the node in degrees.
Source§

fn get_skew_x(&self) -> f32

Gets the X-axis skew angle of the node in degrees.
Source§

fn set_skew_y(&mut self, val: f32)

Sets the Y-axis skew angle of the node in degrees.
Source§

fn get_skew_y(&self) -> f32

Gets the Y-axis skew angle of the node in degrees.
Source§

fn set_visible(&mut self, val: bool)

Sets whether the node is visible.
Source§

fn is_visible(&self) -> bool

Gets whether the node is visible.
Source§

fn set_anchor(&mut self, val: &Vec2)

Sets the anchor point of the node as a Vec2 object.
Source§

fn get_anchor(&self) -> Vec2

Gets the anchor point of the node as a Vec2 object.
Source§

fn set_width(&mut self, val: f32)

Sets the width of the node.
Source§

fn get_width(&self) -> f32

Gets the width of the node.
Source§

fn set_height(&mut self, val: f32)

Sets the height of the node.
Source§

fn get_height(&self) -> f32

Gets the height of the node.
Source§

fn set_size(&mut self, val: &Size)

Sets the size of the node as a Size object.
Source§

fn get_size(&self) -> Size

Gets the size of the node as a Size object.
Source§

fn set_tag(&mut self, val: &str)

Sets the tag of the node as a string.
Source§

fn get_tag(&self) -> String

Gets the tag of the node as a string.
Source§

fn set_opacity(&mut self, val: f32)

Sets the opacity of the node, should be 0 to 1.0.
Source§

fn get_opacity(&self) -> f32

Gets the opacity of the node, should be 0 to 1.0.
Source§

fn set_color(&mut self, val: &Color)

Sets the color of the node as a Color object.
Source§

fn get_color(&self) -> Color

Gets the color of the node as a Color object.
Source§

fn set_color3(&mut self, val: &Color3)

Sets the color of the node as a Color3 object.
Source§

fn get_color3(&self) -> Color3

Gets the color of the node as a Color3 object.
Source§

fn set_pass_opacity(&mut self, val: bool)

Sets whether to pass the opacity value to child nodes.
Source§

fn is_pass_opacity(&self) -> bool

Gets whether to pass the opacity value to child nodes.
Source§

fn set_pass_color3(&mut self, val: bool)

Sets whether to pass the color value to child nodes.
Source§

fn is_pass_color3(&self) -> bool

Gets whether to pass the color value to child nodes.
Source§

fn set_transform_target(&mut self, val: &dyn INode)

Sets the target node acts as a parent node for transforming this node.
Source§

fn get_transform_target(&self) -> Option<Node>

Gets the target node acts as a parent node for transforming this node.
Source§

fn set_scheduler(&mut self, val: &Scheduler)

Sets the scheduler used for scheduling update and action callbacks.
Source§

fn get_scheduler(&self) -> Scheduler

Gets the scheduler used for scheduling update and action callbacks.
Source§

fn get_children(&self) -> Option<Array>

Gets the children of the node as an Array object, could be None.
Source§

fn get_parent(&self) -> Option<Node>

Gets the parent of the node, could be None.
Source§

fn is_running(&self) -> bool

Gets whether the node is currently running in a scene tree.
Source§

fn is_scheduled(&self) -> bool

Gets whether the node is currently scheduling a function for updates.
Source§

fn get_action_count(&self) -> i32

Gets the number of actions currently running on the node.
Source§

fn get_data(&self) -> Dictionary

Gets additional data stored on the node as a Dictionary object.
Source§

fn set_touch_enabled(&mut self, val: bool)

Sets whether touch events are enabled on the node.
Source§

fn is_touch_enabled(&self) -> bool

Gets whether touch events are enabled on the node.
Source§

fn set_swallow_touches(&mut self, val: bool)

Sets whether the node should swallow touch events.
Source§

fn is_swallow_touches(&self) -> bool

Gets whether the node should swallow touch events.
Source§

fn set_swallow_mouse_wheel(&mut self, val: bool)

Sets whether the node should swallow mouse wheel events.
Source§

fn is_swallow_mouse_wheel(&self) -> bool

Gets whether the node should swallow mouse wheel events.
Source§

fn set_keyboard_enabled(&mut self, val: bool)

Sets whether keyboard events are enabled on the node.
Source§

fn is_keyboard_enabled(&self) -> bool

Gets whether keyboard events are enabled on the node.
Source§

fn set_controller_enabled(&mut self, val: bool)

Sets whether controller events are enabled on the node.
Source§

fn is_controller_enabled(&self) -> bool

Gets whether controller events are enabled on the node.
Source§

fn set_render_group(&mut self, val: bool)

Sets whether to group the node’s rendering with all its recursive children.
Source§

fn is_render_group(&self) -> bool

Gets whether to group the node’s rendering with all its recursive children.
Source§

fn set_show_debug(&mut self, val: bool)

Sets whether debug graphic should be displayed for the node.
Source§

fn is_show_debug(&self) -> bool

Gets whether debug graphic should be displayed for the node.
Source§

fn set_render_order(&mut self, val: i32)

Sets the rendering order number for group rendering. Nodes with lower rendering orders are rendered earlier.
Source§

fn get_render_order(&self) -> i32

Gets the rendering order number for group rendering. Nodes with lower rendering orders are rendered earlier.
Source§

fn add_child_with_order_tag(&mut self, child: &dyn INode, order: i32, tag: &str)

Adds a child node to the current node. Read more
Source§

fn add_child_with_order(&mut self, child: &dyn INode, order: i32)

Adds a child node to the current node. Read more
Source§

fn add_child(&mut self, child: &dyn INode)

Adds a child node to the current node. Read more
Source§

fn add_to_with_order_tag( &mut self, parent: &dyn INode, order: i32, tag: &str, ) -> Node

Adds the current node to a parent node. Read more
Source§

fn add_to_with_order(&mut self, parent: &dyn INode, order: i32) -> Node

Adds the current node to a parent node. Read more
Source§

fn add_to(&mut self, parent: &dyn INode) -> Node

Adds the current node to a parent node. Read more
Source§

fn remove_child(&mut self, child: &dyn INode, cleanup: bool)

Removes a child node from the current node. Read more
Source§

fn remove_child_by_tag(&mut self, tag: &str, cleanup: bool)

Removes a child node from the current node by tag. Read more
Source§

fn remove_all_children(&mut self, cleanup: bool)

Removes all child nodes from the current node. Read more
Source§

fn remove_from_parent(&mut self, cleanup: bool)

Removes the current node from its parent node. Read more
Source§

fn move_to_parent(&mut self, parent: &dyn INode)

Moves the current node to a new parent node without triggering node events. Read more
Source§

fn cleanup(&mut self)

Cleans up the current node.
Source§

fn get_child_by_tag(&mut self, tag: &str) -> Option<Node>

Gets a child node by tag. Read more
Source§

fn schedule(&mut self, update_func: Box<dyn FnMut(f64) -> bool>)

Schedules a main function to run every frame. Call this function again to replace the previous scheduled main function or coroutine. Read more
Source§

fn unschedule(&mut self)

Unschedules the current node’s scheduled main function.
Source§

fn convert_to_node_space(&mut self, world_point: &Vec2) -> Vec2

Converts a point from world space to node space. Read more
Source§

fn convert_to_world_space(&mut self, node_point: &Vec2) -> Vec2

Converts a point from node space to world space. Read more
Source§

fn convert_to_window_space( &mut self, node_point: &Vec2, callback: Box<dyn FnMut(&Vec2)>, )

Converts a point from node space to world space. Read more
Source§

fn each_child( &mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>, ) -> bool

Calls the given function for each child node of this node. Read more
Source§

fn traverse(&mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>) -> bool

Traverses the node hierarchy starting from this node and calls the given function for each visited node. The nodes without TraverseEnabled flag are not visited. Read more
Source§

fn traverse_all( &mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>, ) -> bool

Traverses the entire node hierarchy starting from this node and calls the given function for each visited node. Read more
Source§

fn run_action_def(&mut self, def: ActionDef, looped: bool) -> f32

Runs an action defined by the given action definition on this node. Read more
Source§

fn run_action(&mut self, action: &Action, looped: bool) -> f32

Runs an action on this node. Read more
Source§

fn stop_all_actions(&mut self)

Stops all actions running on this node.
Source§

fn perform_def(&mut self, action_def: ActionDef, looped: bool) -> f32

Runs an action defined by the given action definition right after clearing all the previous running actions. Read more
Source§

fn perform(&mut self, action: &Action, looped: bool) -> f32

Runs an action on this node right after clearing all the previous running actions. Read more
Source§

fn stop_action(&mut self, action: &Action)

Stops the given action running on this node. Read more
Source§

fn align_items_vertically(&mut self, padding: f32) -> Size

Vertically aligns all child nodes within the node using the given size and padding. Read more
Source§

fn align_items_vertically_with_size( &mut self, size: &Size, padding: f32, ) -> Size

Vertically aligns all child nodes within the node using the given size and padding. Read more
Source§

fn align_items_horizontally(&mut self, padding: f32) -> Size

Horizontally aligns all child nodes within the node using the given size and padding. Read more
Source§

fn align_items_horizontally_with_size( &mut self, size: &Size, padding: f32, ) -> Size

Horizontally aligns all child nodes within the node using the given size and padding. Read more
Source§

fn align_items(&mut self, padding: f32) -> Size

Aligns all child nodes within the node using the given size and padding. Read more
Source§

fn align_items_with_size(&mut self, size: &Size, padding: f32) -> Size

Aligns all child nodes within the node using the given size and padding. Read more
Source§

fn move_and_cull_items(&mut self, delta: &Vec2)

Moves and changes child nodes’ visibility based on their position in parent’s area. Read more
Source§

fn attach_ime(&mut self)

Attaches the input method editor (IME) to the node. Makes node recieving “AttachIME”, “DetachIME”, “TextInput”, “TextEditing” events.
Source§

fn detach_ime(&mut self)

Detaches the input method editor (IME) from the node.
Source§

fn grab(&mut self) -> Grabber

Creates a texture grabber for the specified node. Read more
Source§

fn grab_with_size(&mut self, grid_x: i32, grid_y: i32) -> Grabber

Creates a texture grabber for the specified node with a specified grid size. Read more
Source§

fn stop_grab(&mut self)

Removes the texture grabber for the specified node.
Source§

fn set_transform_target_null(&mut self)

Removes the transform target for the specified node.
Source§

fn slot(&mut self, event_name: &str, handler: Box<dyn FnMut(&mut CallStack)>)

Associates the given handler function with the node event. Read more
Source§

fn gslot(&mut self, event_name: &str, handler: Box<dyn FnMut(&mut CallStack)>)

Associates the given handler function with a global event. Read more
Source§

fn emit(&mut self, name: &str, stack: &CallStack)

Emits an event to a node, triggering the event handler associated with the event name. Read more
Source§

fn on_update(&mut self, update_func: Box<dyn FnMut(f64) -> bool>)

Schedules a function to run every frame. Call this function again to schedule multiple functions. Read more
Source§

fn on_render(&mut self, render_func: Box<dyn FnMut(f64) -> bool>)

Registers a callback for event triggered when the node is entering the rendering phase. The callback is called every frame, and ensures that its call order is consistent with the rendering order of the scene tree, such as rendering child nodes after their parent nodes. Recommended for calling vector drawing functions. Read more
Source§

impl IObject for AudioSource

Source§

fn raw(&self) -> i64

Source§

fn obj(&self) -> &dyn IObject

Source§

fn as_any(&self) -> &dyn Any

Source§

fn get_id(&self) -> i32

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.