Sound effect object used to play embedded sounds.
Static functions
static getPan (type : String) : Float
Return a sound type's pan setting.
This factors in global panning. See HXP.pan
.
Parameters:
type | The type to get the pan from. |
Returns:
The pan for the type.
static getVolume (type : String) : Float
Return a sound type's volume setting.
This factors in global volume. See HXP.volume
.
Parameters:
type | The type to get the volume from. |
Returns:
The volume for the type.
static onGlobalUpdated (updatePan : Bool) : Void
Called by HXP
when global volume or panning are changed
on native targets. Updates all sounds to the correct volume
or pan, depending on the updatePan setting.
Parameters:
updatePan | True indicates pan changed, false indicates volume changed. |
static setPan (type : String, pan : Float) : Void
Set a sound type's pan. Sfx instances of this type will add this pan to their own.
Parameters:
type | The type to set. | |
pan | The pan value. |
static setVolume (type : String, volume : Float) : Void
Set a sound type's volume. Sfx instances of this type will multiply their volume by this value.
Parameters:
type | The type to set. | |
volume | The volume value. |
Constructor
new (source : Dynamic, complete : Void ->Void, ) : Void
Creates a sound effect from an embedded source. Store a reference to this object so that you can play the sound using play() or loop().
Parameters:
source | The embedded sound class to use. | |
complete | Optional callback function for when the sound finishes playing. |
Variables
pan : Float
Alter the panning factor (a value from -1 to 1) of the sound during playback. Panning only applies to mono sounds. It is ignored on stereo.
type : String
Change the sound type. This an arbitrary string you can use to group sounds to mute or pan en masse.
Functions
loop (vol : Float = 1, pan : Float = 0) : Void
Plays the sound looping. Will loop continuously until you call stop(), play(), or loop() again.
Parameters:
vol | Volume factor, a value from 0 to 1. | |
pan | Panning factor, a value from -1 to 1. |
play (volume : Float = 1, pan : Float = 0, loop : Bool = false) : Void
Plays the sound once.
Parameters:
vol | Volume factor, a value from 0 to 1. | |
pan | Panning factor, a value from -1 to 1. | |
loop | If the audio should loop infinitely |
stop () : Bool
Stops the sound if it is currently playing.
Returns:
If the sound was stopped.