SgAudio¶
Represents a non-positional audio source in the scene graph. Used to play background music or UI sounds that are not tied to any 3D location. Ideal for ambient tracks or global sound effects.
Inherits from¶
Usage¶
To use this class, add the following require at the top of your script:
local SgAudio = require 'engine/sceneobjects/sgaudio'
Reference¶
- class SgAudio¶
- module:
- create(options, parent)¶
Create a new audio object in the scenegraph.
- Parameters:
options (
table
) – A table of options to fill the parametersparent (
SceneObject
) – The parent scene object to add this to
- Returns:
a promise which will resolve to the created object
- Return type:
Promise
- play(force)¶
playback the audio
- Parameters:
force (
boolean
) – Force the sound to replay even if it is already playing
- stop()¶
stop the audio
- isPlaying()¶
Checks if the audio is playing
- Returns:
true, if sound is playing, false otherwise
- Return type:
boolean
- setPlaybackRate(value)¶
- Parameters:
value (
any
)
- getPlaybackRate()¶
- getAudioCollectionEntry()¶
- setAudioCollectionEntry(name)¶
- Parameters:
name (
any
)