summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/game/Ctrl.java16
-rw-r--r--core/src/ch/asynk/tankontank/screens/GameScreen.java19
2 files changed, 20 insertions, 15 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java
index c42de49..a3d1855 100644
--- a/core/src/ch/asynk/tankontank/game/Ctrl.java
+++ b/core/src/ch/asynk/tankontank/game/Ctrl.java
@@ -26,6 +26,7 @@ public class Ctrl implements Disposable
public Player player;
public Player opponent;
public boolean blockMap;
+ public boolean blockHud;
private State selectState;
private State pathState;
@@ -67,6 +68,7 @@ public class Ctrl implements Disposable
this.hud = new Hud(this, game);
this.blockMap = false;
+ this.blockHud = false;
player.turnStart();
hud.playerInfo.update(player, battle.getHudPosition(player));
@@ -201,15 +203,21 @@ public class Ctrl implements Disposable
this.state.enter(normal);
}
- public void touchDown(float x, float y)
+ public void touchDown(float hx, float hy, float mx, float my)
{
- if (!blockMap && state.downInMap(x, y))
+ if (!blockHud && hud.touchDown(hx, hy))
+ return;
+
+ if (!blockMap && state.downInMap(mx, my))
state.touchDown();
}
- public void touchUp(float x, float y)
+ public void touchUp(float hx, float hy, float mx, float my)
{
- if (!blockMap && state.upInMap(x, y))
+ if (!blockHud && hud.touchUp(hx, hy))
+ return;
+
+ if (!blockMap && state.upInMap(mx, my))
state.touchUp();
}
diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java
index 2eb3810..9e82764 100644
--- a/core/src/ch/asynk/tankontank/screens/GameScreen.java
+++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java
@@ -56,7 +56,8 @@ public class GameScreen implements Screen
// private boolean blocked;
// private float inputDelay = 0f;
private Vector2 dragPos = new Vector2();
- private Vector3 touchPos = new Vector3();
+ private Vector3 mapTouch = new Vector3();
+ private Vector3 hudTouch = new Vector3();
private Vector2 screenToWorld = new Vector2();
public GameScreen(final TankOnTank game)
@@ -123,11 +124,9 @@ public class GameScreen implements Screen
if (button == Input.Buttons.LEFT) {
dragPos.set(x, 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);
- }
+ unprojectToHud(x, y, hudTouch);
+ unprojectToMap(x, y, mapTouch);
+ ctrl.touchDown(hudTouch.x, hudTouch.y, mapTouch.x, mapTouch.y);
}
}
return true;
@@ -138,11 +137,9 @@ public class GameScreen implements Screen
// if (blocked) return true;
if (button == Input.Buttons.LEFT) {
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);
- }
+ unprojectToHud(x, y, hudTouch);
+ unprojectToMap(x, y, mapTouch);
+ ctrl.touchUp(hudTouch.x, hudTouch.y, mapTouch.x, mapTouch.y);
}
}
// blocked = true;