From d8797c65eb7ebd7ab432ff4726186c8b80777680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 6 Oct 2014 19:38:41 +0200 Subject: GameCtrl: replace inAnimation() with mayProcessTouch() --- core/src/ch/asynk/tankontank/game/GameCtrl.java | 4 ++-- core/src/ch/asynk/tankontank/game/Hud.java | 4 ++-- core/src/ch/asynk/tankontank/screens/GameScreen.java | 20 ++++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core/src/ch/asynk/tankontank/game/GameCtrl.java b/core/src/ch/asynk/tankontank/game/GameCtrl.java index c22629e..d662f0a 100644 --- a/core/src/ch/asynk/tankontank/game/GameCtrl.java +++ b/core/src/ch/asynk/tankontank/game/GameCtrl.java @@ -53,9 +53,9 @@ public class GameCtrl implements Disposable factory.dispose(); } - public boolean inAnimation() + public boolean mayProcessTouch() { - return (state == animationState); + return (state != animationState); } public void animationDone() diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index 26b986f..e781305 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -147,7 +147,7 @@ public class Hud implements Disposable public boolean touchDown(float x, float y) { - if (ctrl.inAnimation() || !rect.contains(x,y)) return false; + if (!rect.contains(x,y)) return false; if (cancelAct.hit(x, y)) { ctrl.abort(); @@ -159,7 +159,7 @@ public class Hud implements Disposable public boolean touchUp(float x, float y) { - if (ctrl.inAnimation() || !rect.contains(x,y)) return false; + if (!rect.contains(x,y)) return false; if (moveAct.hit(x, y)) { moveAct.setOn(); diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java index e3f6a65..696cfd1 100644 --- a/core/src/ch/asynk/tankontank/screens/GameScreen.java +++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java @@ -112,10 +112,12 @@ public class GameScreen implements Screen { if (button == Input.Buttons.LEFT) { dragPos.set(x, y); - unprojectToHud(x, y, touchPos); - if (!ctrl.hud.touchDown(touchPos.x, touchPos.y)) { - unprojectToMap(x, y, touchPos); - ctrl.touchDown(touchPos.x, touchPos.y); + if (ctrl.mayProcessTouch()) { + unprojectToHud(x, y, touchPos); + if (!ctrl.hud.touchDown(touchPos.x, touchPos.y)) { + unprojectToMap(x, y, touchPos); + ctrl.touchDown(touchPos.x, touchPos.y); + } } } @@ -125,10 +127,12 @@ public class GameScreen implements Screen public boolean touchUp(int x, int y, int pointer, int button) { if (button == Input.Buttons.LEFT) { - unprojectToHud(x, y, touchPos); - if (!ctrl.hud.touchUp(touchPos.x, touchPos.y)) { - unprojectToMap(x, y, touchPos); - ctrl.touchUp(touchPos.x, touchPos.y); + if (ctrl.mayProcessTouch()) { + unprojectToHud(x, y, touchPos); + if (!ctrl.hud.touchUp(touchPos.x, touchPos.y)) { + unprojectToMap(x, y, touchPos); + ctrl.touchUp(touchPos.x, touchPos.y); + } } } return true; -- cgit v1.1-2-g2b99