Playing Audio

File names may vary depending on your assets.

public class SceneNameHere extends Scene {

    private Audio audioOnClick = new Audio("Assets/myAudio.wav");

    public SceneNameHere(Game game) {
        super(game);

    }

    @Override
    public void Initialize() {



    }

    @Override
    public void Update() {

        if(Input.mouseClicked) {
            if(!audioOnClick.isPlaying()) {
                audioOnClick.play();
            }
        }

    }

    @Override
    public void Render(Graphics g) {


    }


}

Last updated