diff options
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/hud/UnitDock.java | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java b/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java index 458821e..a34049d 100644 --- a/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java +++ b/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java @@ -109,7 +109,12 @@ public class UnitDock extends Bg implements Animation @Override public boolean hit(float x, float y) { - return (visible && scaledRect.contains(x, y)); + if (!visible || !scaledRect.contains(x, y)) + return false; + int i = (int) ((scaledRect.y + scaledRect.height - y) / (scaledRect.height / units.size())); + selectedUnit = units.get(i); + selected.setPosition(selectedUnit.getX() - padding, selectedUnit.getY() - padding, selectedUnit.getWidth() + (2 * padding), selectedUnit.getHeight() + (2 * padding)); + return true; } public void drag(int dx, int dy) @@ -118,14 +123,6 @@ public class UnitDock extends Bg implements Animation compute(); } - public Unit select(float x, float y) - { - int i = (int) ((scaledRect.y + scaledRect.height - y) / (scaledRect.height / units.size())); - selectedUnit = units.get(i); - selected.setPosition(selectedUnit.getX() - padding, selectedUnit.getY() - padding, selectedUnit.getWidth() + (2 * padding), selectedUnit.getHeight() + (2 * padding)); - return selectedUnit; - } - public void hide() { if (!visible) return; |