class flixel.system.frontEnds.SoundFrontEnd

Available on all platforms

Instance Fields

var list:FlxTypedGroup<FlxSound>

A list of all the sounds being played in the game.

var music:FlxSound

A handy container for a background music object.

var muteKeys:Array<String>

The keys used to mute / unmute the game (see FlxG.keys for the keys available). * Default keys: 0 (and numpad 0). Set to null to deactivate.

var muted:Bool

Whether or not the game sounds are muted.

var soundTrayEnabled:Bool

Whether or not the soundTray should be shown when any of the * volumeUp-, volumeDown- or muteKeys is pressed.

var volume:Float

Set this to a number between 0 and 1 to change the global volume.

var volumeDownKeys:Array<String>

The keys to decrease volume (see FlxG.keys for the keys available). * Default keys: - (and numpad -). Set to null to deactivate.

var volumeUpKeys:Array<String>

The key codes used to increase volume (see FlxG.keys for the keys available). * Default keys: + (and numpad +). Set to null to deactivate.

function cache(EmbeddedSound:String):Sound

Method for sound caching (especially useful on mobile targets). The game may freeze * for some time the first time yout try to play a sound if you don't use this method. * *

EmbeddedSound

Name of sound assets specified in your .xml project file *

returns

Cached Sound object

function destroy(?ForceDestroy:Bool = false):Void

Called by FlxGame on state changes to stop and destroy sounds. * *

ForceDestroy

Kill sounds even if persist is true.

function load(?EmbeddedSound:Dynamic = null, ?Volume:Float = 1, ?Looped:Bool = false, ?AutoDestroy:Bool = false, ?AutoPlay:Bool = false, ?URL:String = null, ?OnComplete:Void ->Void = null):FlxSound

Creates a new sound object. * *

EmbeddedSound

The embedded sound resource you want to play. To stream, use the optional URL parameter instead. *

Volume

How loud to play it (0 to 1). *

Looped

Whether to loop this sound. *

AutoDestroy

Whether to destroy this sound when it finishes playing. Leave this value set to "false" if you want to re-use this FlxSound instance. *

AutoPlay

Whether to play the sound. *

URL

Load a sound from an external web resource instead. Only used if EmbeddedSound = null. *

returns

A FlxSound object.

function pause():Void

Pause all sounds currently playing.

function play(EmbeddedSound:String, ?Volume:Float = 1, ?Looped:Bool = false, ?AutoDestroy:Bool = true, ?OnComplete:Void ->Void = null):FlxSound

Plays a sound from an embedded sound. Tries to recycle a cached sound first. * *

EmbeddedSound

The sound you want to play. *

Volume

How loud to play it (0 to 1). *

Looped

Whether to loop this sound. *

AutoDestroy

Whether to destroy this sound when it finishes playing. Leave this value set to "false" if you want to re-use this FlxSound instance. *

returns

The FlxSound object.

function playMusic(Music:Dynamic, ?Volume:Float = 1, ?Looped:Bool = true):Void

Set up and play a looping background soundtrack. * *

Music

The sound file you want to loop in the background. *

Volume

How loud the sound should be, from 0 to 1. *

Looped

Whether to loop this music.

function resume():Void

Resume playing existing sounds.

function stream(URL:String, ?Volume:Float = 1, ?Looped:Bool = false, ?AutoDestroy:Bool = true, ?OnComplete:Void ->Void = null):FlxSound

Creates a new sound object from a URL. * NOTE: Just calls FlxG.loadSound() with AutoPlay == true. * *

URL

The URL of the sound you want to play. *

Volume

How loud to play it (0 to 1). *

Looped

Whether or not to loop this sound. *

AutoDestroy

Whether to destroy this sound when it finishes playing. Leave this value set to "false" if you want to re-use this FlxSound instance. *

returns

A FlxSound object.

function volumeHandler(:Float):Void

Set this hook to get a callback whenever the volume changes. * Function should take the form myVolumeHandler(Volume:Number).