diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-04 16:22:41 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-04 16:22:41 +0100 |
commit | deab892c2799267687ed1aaf9fb53c2299aa65f2 (patch) | |
tree | 80c673b89a1086bb90bf6c6a21e58c2004bf692a /core | |
parent | c54d68e0be7fc93d049c24001363301e4a76c9fe (diff) | |
download | RustAndDust-deab892c2799267687ed1aaf9fb53c2299aa65f2.zip RustAndDust-deab892c2799267687ed1aaf9fb53c2299aa65f2.tar.gz |
Hurd: improve image touch scheme
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 25 |
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; |