added "card_shuffled" and "card_played" sounds
parent
c5debe13e8
commit
f8ef429a9c
@ -0,0 +1,21 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.listeners;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Button;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.util.SoundManager;
|
||||
|
||||
public class ButtonClickListener extends ChangeListener {
|
||||
private final SoundManager sounds;
|
||||
|
||||
public ButtonClickListener(SoundManager sounds) {
|
||||
this.sounds = sounds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (actor instanceof Button) {
|
||||
sounds.sfxClick();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.util;
|
||||
|
||||
import com.badlogic.gdx.audio.Sound;
|
||||
import lombok.Setter;
|
||||
|
||||
public class SoundManager {
|
||||
public static final float CARD_SHUFFLE_DURATION = 4.2f;
|
||||
|
||||
private final WizardAssetManager assets;
|
||||
|
||||
@Setter
|
||||
private float sfxVolume = 1;
|
||||
|
||||
private final Sound click;
|
||||
private final Sound cardPlayed;
|
||||
private final Sound cardShuffle;
|
||||
|
||||
public SoundManager(WizardAssetManager assets) {
|
||||
this.assets = assets;
|
||||
assets.load(WizardAssetManager.SFX_CLICK, Sound.class);
|
||||
assets.load(WizardAssetManager.SFX_CARD_PLAYED, Sound.class);
|
||||
assets.load(WizardAssetManager.SFX_CARD_SHUFFLE, Sound.class);
|
||||
assets.finishLoading();
|
||||
|
||||
this.click = assets.get(WizardAssetManager.SFX_CLICK);
|
||||
this.cardPlayed = assets.get(WizardAssetManager.SFX_CARD_PLAYED);
|
||||
this.cardShuffle = assets.get(WizardAssetManager.SFX_CARD_SHUFFLE);
|
||||
}
|
||||
|
||||
public void sfxClick() {
|
||||
this.click.play(sfxVolume);
|
||||
}
|
||||
|
||||
public void sfxShuffle() {
|
||||
this.cardShuffle.play(sfxVolume);
|
||||
}
|
||||
|
||||
public void sfxPlayCard() {
|
||||
this.cardPlayed.play(sfxVolume);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
assets.unload(WizardAssetManager.SFX_CLICK);
|
||||
assets.unload(WizardAssetManager.SFX_CARD_PLAYED);
|
||||
assets.unload(WizardAssetManager.SFX_CARD_SHUFFLE);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue