docsReading time: 2 minutes

2D Audio

The Sound Engine -

The 2D SoundEngine provides all methods to playback sounds and music in your game. It allows to define the 2D coordinates of the sound or even pass in the source entity of the sound which will adjust the position according to the position of the Entity.

The LITIENGINE sound engine supports .wav, .mp3 and .ogg by default.

If you need to support other audio codecs, you have to write an own SPI implementation and inject it to your project. For more information, read the Official Java Documentation on Service Provider Interfaces.

Sound mySound = Resources.sounds().get("my-sound.ogg");

// play the sound;

// play the sound at environment location (50/50), 50, 50);

// play the sound at location of an entity, myEntity);

// play background music"my-music.ogg"));

// use the SoundPlayback to react to events
SoundPlayback playback =;
playback.addSoundPlaybackListener(new SoundPlaybackListener() {

  public void finished(SoundEvent event) {
  public void cancelled(SoundEvent event) {

If a location (or related Entity) is specified when playing a Sound, the engine will adjust the pan and volume relative to the current listener location. By default, this location will be the focus of the game's Camera.

Josef-FriedrichLast updated 1 month ago
On this page