summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-12-17 16:12:49 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-12-17 16:12:49 +0100
commit593d1f909e8f5bee21e9e4fbe42fcfebda3f4d79 (patch)
treeafaf44ac4830b3eb8d7c45e572958d5f59e351e5 /core
parentde4d543e48341118386f52012dd8bcdbc62c5757 (diff)
downloadRustAndDust-593d1f909e8f5bee21e9e4fbe42fcfebda3f4d79.zip
RustAndDust-593d1f909e8f5bee21e9e4fbe42fcfebda3f4d79.tar.gz
PlayerInfo: add position and updatePosition()
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java b/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java
index 72daf1a..7489fd4 100644
--- a/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java
+++ b/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java
@@ -33,10 +33,12 @@ public class PlayerInfo implements Disposable, Drawable, Animation
private LabelImage aps;
private LabelImage reinforcement;
public UnitDock unitDock;
+ private Position position;
public PlayerInfo(Ctrl ctrl, BitmapFont font, TextureAtlas atlas)
{
this.ctrl = ctrl;
+ this.position = Position.MIDDLE_CENTER;
usFlag = new Sprite(atlas.findRegion("us-flag"));
geFlag = new Sprite(atlas.findRegion("ge-flag"));
turns = new LabelImage(atlas.findRegion("turns"), font, 5f);
@@ -54,8 +56,22 @@ public class PlayerInfo implements Disposable, Drawable, Animation
unitDock.dispose();
}
+ public void updatePosition()
+ {
+ float dx = (position.getX(usFlag.getWidth()) - usFlag.getX());
+ float dy = (position.getY(usFlag.getHeight()) - usFlag.getY());
+ usFlag.translate(dx, dy);
+ geFlag.translate(dx, dy);
+ turns.translate(dx, dy);
+ aps.translate(dx, dy);
+ reinforcement.translate(dx, dy);
+ unitDock.translate(dx, dy);
+ }
+
public void setPosition(Position position)
{
+ this.position = position;
+
float width = (usFlag.getWidth() + turns.getWidth() + aps.getWidth() + (2 * PADDING));
float height = (usFlag.getHeight() + reinforcement.getHeight() + (1 * PADDING));
float x = position.getX(width);