From 0bfea1c03f0ab6fef63e29e8aa08954fb1bb7bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 17 Dec 2014 16:47:38 +0100 Subject: UnitDock: add translate() --- .../src/ch/asynk/tankontank/game/hud/UnitDock.java | 24 ++++++++++++++++++---- 1 file 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; -- cgit v1.1-2-g2b99