summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/ch/asynk/tankontank/game/GameCtrl.java3
-rw-r--r--core/src/ch/asynk/tankontank/game/Hud.java12
2 files changed, 12 insertions, 3 deletions
diff --git a/core/src/ch/asynk/tankontank/game/GameCtrl.java b/core/src/ch/asynk/tankontank/game/GameCtrl.java
index fc4df91..38057d6 100644
--- a/core/src/ch/asynk/tankontank/game/GameCtrl.java
+++ b/core/src/ch/asynk/tankontank/game/GameCtrl.java
@@ -27,10 +27,9 @@ public class GameCtrl implements Disposable
this.game = game;
this.factory = new GameFactory(game.manager);
+ this.hud = new Hud(game, this);
this.map = factory.getMap(this, game.manager, GameFactory.MapType.MAP_A);
- this.hud = new Hud(game);
-
this.noneState = new GameStateNone(this, map);
this.pathState = new GameStatePath();
this.directionState = new GameStateDirection();
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java
index c9e47ab..866c6a1 100644
--- a/core/src/ch/asynk/tankontank/game/Hud.java
+++ b/core/src/ch/asynk/tankontank/game/Hud.java
@@ -73,6 +73,7 @@ class ActionBtn implements Disposable
public class Hud implements Disposable
{
private final TankOnTank game;
+ private final GameCtrl ctrl;
private ActionBtn flagAct;
private ActionBtn moveAct;
@@ -83,9 +84,10 @@ public class Hud implements Disposable
private Rectangle rect;
private float elapsed;
- public Hud(final TankOnTank game)
+ public Hud(final TankOnTank game, final GameCtrl ctrl)
{
this.game = game;
+ this.ctrl = ctrl;
TextureAtlas atlas = game.manager.get("data/assets.atlas", TextureAtlas.class);
@@ -140,6 +142,7 @@ public class Hud implements Disposable
if (!rect.contains(x,y)) return false;
if (cancelAct.hit(x, y)) {
+ ctrl.abort();
cancelAct.toggle();
}
@@ -152,11 +155,18 @@ public class Hud implements Disposable
if (moveAct.hit(x, y)) {
moveAct.setOn();
+ ctrl.setState(GameState.State.MOVE, false);
} else if (rotateAct.hit(x, y)) {
rotateAct.setOn();
+ ctrl.setState(GameState.State.ROTATE, false);
} else if (attackAct.hit(x, y)) {
attackAct.setOn();
+ ctrl.setState(GameState.State.ATTACK, false);
} else if (cancelAct.hit(x, y)) {
+ ctrl.abort();
+ moveAct.setOff();
+ rotateAct.setOff();
+ attackAct.setOff();
cancelAct.toggle();
}