summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-04 16:22:41 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-04 16:22:41 +0100
commitdeab892c2799267687ed1aaf9fb53c2299aa65f2 (patch)
tree80c673b89a1086bb90bf6c6a21e58c2004bf692a /core/src
parentc54d68e0be7fc93d049c24001363301e4a76c9fe (diff)
downloadRustAndDust-deab892c2799267687ed1aaf9fb53c2299aa65f2.zip
RustAndDust-deab892c2799267687ed1aaf9fb53c2299aa65f2.tar.gz
Hurd: improve image touch scheme
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/game/Hud.java25
1 files changed, 13 insertions, 12 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java
index 9a38cfe..1ab66ee 100644
--- a/core/src/ch/asynk/tankontank/game/Hud.java
+++ b/core/src/ch/asynk/tankontank/game/Hud.java
@@ -32,6 +32,7 @@ public class Hud implements Disposable
private Msg msg;
private Button btn;
+ private Object hit;
public Button moveBtn;
public Button rotateBtn;
public Button promoteBtn;
@@ -211,13 +212,14 @@ public class Hud implements Disposable
public boolean touchDown(float x, float y)
{
btn = null;
+ hit = null;
if (turns.hit(x,y))
- return true;
+ hit = turns;
else if (unitDock.hit(x, y))
- return true;
+ hit = unitDock;
else if (reinforcement.hit(x, y))
- return true;
+ hit = reinforcement;
else if (actionsBg.hit(x,y)) {
if (moveBtn.hit(x, y))
btn = moveBtn;
@@ -265,15 +267,14 @@ public class Hud implements Disposable
if (setOn) btn.setOn();
else btn.setOff();
btn = null;
- }
- else if (turns.hit(x, y)) {
- ctrl.endPlayerTurn();
- }
- else if (reinforcement.hit(x, y)) {
- unitDock.toggle();
- }
- else if (unitDock.hit(x, y)) {
- System.err.println("TODO unitDock touched");
+ } else if (hit != null) {
+ if ((hit == turns) && turns.hit(x, y))
+ ctrl.endPlayerTurn();
+ else if ((hit == reinforcement) && reinforcement.hit(x, y))
+ unitDock.toggle();
+ else if ((hit == unitDock) && unitDock.hit(x, y))
+ System.err.println("TODO : unitDock hit");
+ hit = null;
} else
return false;