summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-03-31 23:03:51 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-03-31 23:03:51 +0200
commitdf21477a5b527a1f7c787df81f679e6aa6251560 (patch)
treec458ced8d3cbe9deb7416a4db89c1239ed483ebe /core/src/ch/asynk
parentc08c66b2ba227aa2f6d630abbad70f8860a66159 (diff)
downloadRustAndDust-df21477a5b527a1f7c787df81f679e6aa6251560.zip
RustAndDust-df21477a5b527a1f7c787df81f679e6aa6251560.tar.gz
UnitDock: hit(float, float) swallows Unit select(float, float)
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/rustanddust/game/hud/UnitDock.java15
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;