AudioComponent¶
AudioComponent ¶
enable
property
writable
¶
enable: bool
Whether this component is active. Disabling unloads every track's sound.
listener
property
writable
¶
listener: bool
Whether this component is the scene's active audio listener. Setting this to True unsets listener on any other AudioComponent in the scene.
add_component ¶
add_component(component_class: Any) -> typing.Any
Attach a new component of the given type to this component's owning Object.
Example
render = self.add_component(RenderComponent)
add_object ¶
add_object(obj: Object, parent: Object = None) -> Object
Add a newly created Object to the scene, optionally parented to another Object
add_track ¶
add_track(name: str = '', path: str = '', streaming: bool = False, loop: bool = False, volume: SupportsFloat | SupportsIndex = 1.0) -> str
Add a new audio track and return its actual name. If name collides with an existing track, a numeric suffix is appended to keep it unique, so check the returned value rather than assuming it matches what you passed in.
Example
track = audio.add_track('Footstep', 'res://sfx/step.wav')
audio.play(track)
get_component ¶
get_component(component_class: Any) -> typing.Any
Look up a component on this Object
get_streaming ¶
get_streaming(name: str) -> bool
Whether the given track streams from disk rather than being fully decoded into memory
has_component ¶
has_component(component_class: Any) -> bool
Check whether this component's owning Object has a component of the given type
play ¶
play(name: str) -> None
Start (or resume) playback of the track with the given name.
Example
audio.play('Footstep')
remove_component ¶
remove_component(component_class: Any) -> None
Remove a component of the given type from this component's owning Object
set_audio_path ¶
set_audio_path(name: str, path: str) -> None
Set the audio file (a res:// path) for the given track. (Re)loads the sound immediately using its current streaming/loop settings.
set_loop ¶
set_loop(name: str, loop: bool) -> None
Set loop for the given track. Reloads the sound if a path is set.
set_streaming ¶
set_streaming(name: str, streaming: bool) -> None
Set streaming for the given track. Reloads the sound if a path is set.
set_volume ¶
set_volume(name: str, volume: SupportsFloat | SupportsIndex) -> None
Set volume for the given track. Only takes effect once the track's sound is loaded.