From df21477a5b527a1f7c787df81f679e6aa6251560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 31 Mar 2016 23:03:51 +0200 Subject: UnitDock: hit(float, float) swallows Unit select(float, float) --- core/src/ch/asynk/rustanddust/game/hud/UnitDock.java | 15 ++++++--------- 1 file 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; -- cgit v1.1-2-g2b99