summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game/hud
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-12-17 16:47:38 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-12-17 16:47:38 +0100
commit0bfea1c03f0ab6fef63e29e8aa08954fb1bb7bfa (patch)
treed743c448d207b3789b09d80936490bf5baee3f1b /core/src/ch/asynk/tankontank/game/hud
parentb525ed807067c70af353ef8beca34135986e8bc3 (diff)
downloadRustAndDust-0bfea1c03f0ab6fef63e29e8aa08954fb1bb7bfa.zip
RustAndDust-0bfea1c03f0ab6fef63e29e8aa08954fb1bb7bfa.tar.gz
UnitDock: add translate()
Diffstat (limited to 'core/src/ch/asynk/tankontank/game/hud')
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/UnitDock.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/UnitDock.java b/core/src/ch/asynk/tankontank/game/hud/UnitDock.java
index de69004..87a9a8d 100644
--- a/core/src/ch/asynk/tankontank/game/hud/UnitDock.java
+++ b/core/src/ch/asynk/tankontank/game/hud/UnitDock.java
@@ -20,12 +20,10 @@ public class UnitDock extends Bg implements Animation
private static final float STEP = 5f;
private final Ctrl ctrl;
- private float padding;
private float y;
private float to;
private float dx;
private float step;
- private Position position;
private boolean show;
private boolean mvtDone;
public Unit selectedUnit;
@@ -36,9 +34,9 @@ public class UnitDock extends Bg implements Animation
private Matrix4 transform;
private Rectangle scaledRect;
- public UnitDock(Ctrl ctrl, TextureRegion bg, TextureRegion selected, float padding)
+ public UnitDock(Ctrl ctrl, TextureRegion region, TextureRegion selected, float padding)
{
- super(bg);
+ super(region);
this.ctrl = ctrl;
this.padding = padding;
this.mvtDone = true;
@@ -50,6 +48,24 @@ public class UnitDock extends Bg implements Animation
this.visible = false;
}
+ @Override
+ public void translate(float _dx, float _dy)
+ {
+ this.y += _dy;
+ if (!visible) return;
+ super.translate(_dx, _dy);
+ for (Unit unit : units)
+ unit.translate(_dx, _dy);
+ transform.idt();
+ transform.translate((rect.x + dx), (rect.y + rect.height), 0).scale(SCALE, SCALE, 0).translate(-rect.x, - (rect.y + rect.height), 0);
+ point.set(rect.x, rect.y, 0).mul(transform);
+ scaledRect.x = point.x;
+ scaledRect.y = point.y;
+ point.set((rect.x + rect.width), (rect.y + rect.height), 0).mul(transform);
+ scaledRect.width = point.x - scaledRect.x;
+ scaledRect.height = point.y - scaledRect.y;
+ }
+
public void setPosition(Position position, float y)
{
this.position = position;