Ability to turn off the sound
This commit is contained in:
parent
59122045c0
commit
df7982d202
@ -18,15 +18,26 @@ public enum Sound {
|
|||||||
EXPLOSION_1("/res/explosion1.wav"),
|
EXPLOSION_1("/res/explosion1.wav"),
|
||||||
EXPLOSION_2("/res/explosion2.wav");
|
EXPLOSION_2("/res/explosion2.wav");
|
||||||
|
|
||||||
|
private static boolean enabled;
|
||||||
private final Clip soundClip;
|
private final Clip soundClip;
|
||||||
|
|
||||||
Sound(String resource) {
|
Sound(String resource) {
|
||||||
soundClip = loadClip(resource);
|
soundClip = loadClip(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setEnabled(boolean enabled) {
|
||||||
|
Sound.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public void play() {
|
public void play() {
|
||||||
soundClip.setFramePosition(0);
|
if (enabled) {
|
||||||
soundClip.start();
|
soundClip.setFramePosition(0);
|
||||||
|
soundClip.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Clip loadClip(String resource) {
|
private Clip loadClip(String resource) {
|
||||||
|
Loading…
Reference in New Issue
Block a user