I already have a working method to play sound effects in my game, but the sounds are all played at the default volume. I want a sound to be more quiet if the distance between the sound effect's origin and the player increases.
Currently I'm using:
public static void play(String sound) {
Clip clip = soundList.get(sound);
clip.setFramePosition(0);
//I want to set the clip's volume here
clip.start();
}
There is something like clip.getLevel(), but there is no setter. How can I set the clip's volume before it starts?
Thanks in advance!