Class l2df.class.component.sound

Last updated 2021-05-28 15:24:22

Sound component.

Inherited from l2df.class.Component class.

Info:

Functions

Sound:added(obj[, kwargs]) Component was added to Entity event.
Sound:removed(obj) Component was removed from Entity event.
Sound:add(obj, file[, sound_id]) Load and add new sound to the list.
Sound:play(obj, sound_id) Play the previously loaded with Sound:add() function sound.
Sound:postupdate(obj) Component post-update event handler.

Tables

Sound Table describing <sound> structure.

Fields

Sound.data.music Background music resource.
Sound.data.looping Background music looping.
Sound.data.sounds Array of sound IDs to be played at the end of the current frame.


Functions

Methods
Sound:added(obj[, kwargs])
Component was added to Entity event. Adds "sound" key to the Entity.C table.

Parameters:

  • obj l2df.class.entity Entity's instance.
  • kwargs table Keyword arguments.
    • music string or love.audio.Source Path to the audio file or userdata with audio source. Links a passed audio resource with this component to play background music when entity is visible and active. (optional)
    • looping boolean True if component should loop the background music. False otherwise. (default false)
    • hidden boolean Applies to entity's hidden state. (default false)
    • sounds {l2df.class.component.sound.Sound,...} Sounds' array to be preloaded with Sound:add() function. (optional)
Sound:removed(obj)
Component was removed from Entity event. Removes "sound" key from Entity.C table.

Parameters:

Sound:add(obj, file[, sound_id])
Load and add new sound to the list.

Parameters:

  • obj l2df.class.entity Entity's instance.
  • file string Path to the sound file. Supported formats: MP3, Ogg Vorbis, WAVE.
  • sound_id string or number Sound's ID to be set explicitly. Assigns automatically if not passed. (optional)

Returns:

    string or number ID of the sound. Usefull when u did not pass it explicitly.
Sound:play(obj, sound_id)
Play the previously loaded with Sound:add() function sound.

Parameters:

Sound:postupdate(obj)
Component post-update event handler.

Parameters:

Tables

Sound
Table describing <sound> structure.

Fields:

  • id string or number Sound's ID. Would be used by Sound:play() function
  • file string Path to the audio file. Supported formats: MP3, Ogg Vorbis, WAVE

Fields

Sound.data.music love.audio.Source
Background music resource. To access use Sound:data() function or Entity.data directly.
Sound.data.looping boolean
Background music looping. To access use Sound:data() function or Entity.data directly.
Sound.data.sounds {number or string,...}
Array of sound IDs to be played at the end of the current frame. To access use Sound:data() function or Entity.data directly.