diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-29 23:10:34 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-29 23:10:34 +0100 |
commit | 7da2aef0c8a4fb04fd90b321e17cbf5bc0eaf754 (patch) | |
tree | 71f5d8429bf6cc7711f0babed3940232126456aa /core/src/ch/asynk/tankontank/game | |
parent | 5835231e0c506ef1f4acd5d610e3103b7ba81c0c (diff) | |
download | RustAndDust-7da2aef0c8a4fb04fd90b321e17cbf5bc0eaf754.zip RustAndDust-7da2aef0c8a4fb04fd90b321e17cbf5bc0eaf754.tar.gz |
UnitDock: fix to and rect.x computation, units orientation
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/hud/UnitDock.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/UnitDock.java b/core/src/ch/asynk/tankontank/game/hud/UnitDock.java index 233fb37..ad9df87 100644 --- a/core/src/ch/asynk/tankontank/game/hud/UnitDock.java +++ b/core/src/ch/asynk/tankontank/game/hud/UnitDock.java @@ -93,16 +93,21 @@ public class UnitDock extends Bg public void show() { - float x = position.getX(rect.width * SCALE); + int n = ctrl.player.reinforcement(); + if (n == 0) { + visible = false; + return; + } + if (mvtDone) { - if(ctrl.player.reinforcement() == 0) - return; units = ctrl.player.reinforcement; rect.width = units.get(0).getWidth() + (2 * padding); - rect.height = ((units.get(0).getHeight() * units.size()) + ((units.size() + 1) * padding)); - rect.x = (position.isLeft() ? (0 - (rect.width * SCALE)) : (x + (rect.width * SCALE))); + rect.height = ((units.get(0).getHeight() * n) + ((n + 1) * padding)); + float scaledWidth = (rect.width * SCALE); + to = position.getX(scaledWidth); + rect.x = to + (position.isLeft() ? -scaledWidth : scaledWidth); rect.y = y - rect.height; - // position units here + // position units float px = rect.x; float py = rect.y + rect.height; float ph = units.get(0).getHeight(); @@ -110,12 +115,13 @@ public class UnitDock extends Bg py -= (ph + padding); // unit.setPosition(px, py, Orientation.SOUTH.r()); unit.centerOn((px + (rect.width / 2)), py + (ph / 2)); - unit.setRotation(Orientation.SOUTH.r()); + unit.setRotation(position.isLeft() ? Orientation.NORTH.r() : Orientation.SOUTH.r()); } + } else { + to = position.getX(rect.width * SCALE); } selectedUnit = null; - to = x; show = true; mvtDone = false; visible = true; |