diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-06 19:38:41 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-06 19:38:41 +0200 |
commit | d8797c65eb7ebd7ab432ff4726186c8b80777680 (patch) | |
tree | 41032bb0402d55199ac284cea01b613f55f63e05 /core/src/ch/asynk/tankontank | |
parent | 7db893e40c861d9d167d1e0a5602c1b19fdf9b88 (diff) | |
download | RustAndDust-d8797c65eb7ebd7ab432ff4726186c8b80777680.zip RustAndDust-d8797c65eb7ebd7ab432ff4726186c8b80777680.tar.gz |
GameCtrl: replace inAnimation() with mayProcessTouch()
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/GameCtrl.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 4 | ||||
-rw-r--r-- | 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; |