sound and input - Vrekt/Lunar GitHub Wiki

Creating and playing sounds

Lets start by creating a new sound.

Sound mySound = new Sound(int ID, File audioFile);
  • ID is the ID of the sound.
  • audioFile is the file which contains the audio.

Now to play our sound we must create new instance of the SoundManager. Its best to have already created one and stored it.

soundManager.playAudio(mySound);

If creating a new Sound object is not feasible you can just use:

mySoundManager.playAudio(audioFile);

To stop playback of the sound use SoundManager#stopPlayingSound(Sound sound);.

mySoundManager.stopPlayingSound(sound);

Mouse and Keyboard input

Lunar provides mouse and keyboard support.

To check and see if a certain key is pressed use InputListener#isKeyPressed(KeyEvent key);.

InputListener.isKeyPressed(KeyEvent.KEY);

To check if the mouse is down.

MouseInput.isMouseDown(); 

Getting the point of the last click.

MouseInput.getLastClick();