[back to index]

Library Reference (v 0.11.0)


For playing sound effects.
Sound.load(soundname:String, volumelevel:Float = 1.0)
Loads in a sound from data/sounds/ - either MP3,OGG or WAV, depending on platform. See "how to add assets.txt" in your data folder for more details. Optionally set a volume level for the sound (0.5 loads it in at half volume, for example.)
Sound.play(soundname:String, ?offsettime:Float = 0.0, ?fadeintime:Float = 0, ?loop:Bool = false, ?panning:Float = 0)
Plays a sound from data/sounds/ folder. Optionally set a startpoint (where 1.0 is 1 seconds into the song), a fade in time (0 means start immediately, 1.0 means fade in for one second), whether or not to loop, and a panning value (between -1 and +1 for left to right).
Sound.stop(soundname:String = "", ?fadeouttime:Float = 0)
If soundname is blank, stop all sound effects from playing. Otherwise, stop any sounds that match with the given soundname. Optionally set a fade out time (0 means stop immediately, 1.0 means fade out for one second)
Gets the length of a given sound file in seconds. 1.5 means one and a half seconds long, for example.
A float between 0 and 1 to set the volume of your application. Affects everything, music and sounds both.
If set, play the named sound effect when the player types something in.