sound¶
The sound module provides a way to play and manage sound effects and background music
- SOUND_COIN: const¶
Procedural coin sound preset (SFXR)
- SOUND_LASER: const¶
Procedural laser sound preset (SFXR)
- SOUND_EXPLOSION: const¶
Procedural explosion sound preset (SFXR)
- SOUND_POWERUP: const¶
Procedural powerup sound preset (SFXR)
- SOUND_HURT: const¶
Procedural hurt sound preset (SFXR)
- SOUND_JUMP: const¶
Procedural jump sound preset (SFXR)
- SOUND_BLIP: const¶
Procedural blip sound preset (SFXR)
- static sound.play(preset[, seed])¶
Plays a preset procedural SFXR sound effect using a given
preset
and optionalseed
- Return type:
- static sound.play(source[, volume = 1, pitch = 1, pan = 0, paused = false])
Plays a
sound.source
in 2D, returning an activesound.instance
object that can be adjusted, paused/resumed and stopped- Return type:
- static sound.play(assetKey[, volume = 1, pitch = 1, pan = 0, paused = false])
Plays a sound using an asset key in 2D, returning an active
sound.instance
object that can be adjusted, paused/resumed and stopped
- static sound.play3d(source[, volume = 1, pitch = 1, paused = false])¶
Plays a
sound.source
in 3D, returning an activesound.instance
object that can be adjusted, paused/resumed and stopped- Return type:
- static sound.play3d(assetKey[, volume = 1, pitch = 1, paused = false])
Plays a sound using an asset key in 3D, returning an active
sound.instance
object that can be adjusted, paused/resumed and stopped- Return type:
- static sound.playBackground(source[, volume = 1, pitch = 1, paused = false])¶
Plays a
sound.source
in the background (no spatialisation), returning an active sound.instance object that can be adjusted, paused/resumed and stopped- Return type:
- static sound.playBackground(assetKey[, volume = 1, pitch = 1, paused = false])
Plays an
asset.key
in the background (no spatialisation), returning an active sound.instance object that can be adjusted, paused/resumed and stopped- Return type:
- static sound.read(assetKey)¶
Reads a
sound.source
using anasset.key
from the filesystemSupported formats are -
wav
,ogg
,mp3
,flac
- Return type:
- static sound.generator(table)¶
- class sound.source¶
A source of sound data to be used with
sound.play
- volume: number¶
Adjusts the default volume of sounds played with this sound source
- loop: boolean¶
Adjusts the default looping state of sounds played with this sound source
- length: number [readonly]¶
Gets the length of this sound source (in seconds)
- class sound.instance¶
An instance of a playing sound from
sound.play
and associated methodsSound instances can be used to monitor and adjust sounds while playing
- volume: number¶
Adjusts the volume of the sound instance
- pitch: number¶
Adjusts the pitch of the sounds (increases/decreases play speed)
- loop: boolean¶
The looping state of the sound instance. When set to true the sound instance will continuously loop
- paused: number¶
Set the paused state of the sound instance
- time: number¶
Get/set the current time of the sound instances play head (in seconds)
- stop()¶
Stop the sound instance from playing