From 16d5333e84dc0a2f981252d49f5cc87c82f513e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 4 Apr 2016 20:27:33 +0200 Subject: Hud: only play sound if toggle option panel happens --- core/src/ch/asynk/rustanddust/game/Hud.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/game/Hud.java b/core/src/ch/asynk/rustanddust/game/Hud.java index 1262a80..01323f8 100644 --- a/core/src/ch/asynk/rustanddust/game/Hud.java +++ b/core/src/ch/asynk/rustanddust/game/Hud.java @@ -184,8 +184,8 @@ public class Hud implements Disposable, Animation public boolean hit(float x, float y, boolean isInAnimation) { if (optionsBtn.hit(x, y)) { - game.playType(); - toggleOptionsPanel(); + if (toggleOptionsPanel()) + game.playType(); return true; } @@ -260,17 +260,18 @@ public class Hud implements Disposable, Animation dialogs.push(dialog); } - private void toggleOptionsPanel() + private boolean toggleOptionsPanel() { if (dialogs.size() > 0) { - if (dialogs.peek() == optionsPanel) { - optionsPanel.close(); - closeDialog(); - } + if (dialogs.peek() != optionsPanel) + return false; + optionsPanel.close(); + closeDialog(); } else { optionsPanel.show(); pushDialog(optionsPanel); } + return true; } public void askExitBoard() -- cgit v1.1-2-g2b99