diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-23 22:36:08 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-01 17:41:28 +0100 |
commit | 3c29b80709c5885c5548a6fcaccfe35189b19b41 (patch) | |
tree | 040f7e73ccf17a2f7fa101d5305acaa3fc7cf99c | |
parent | 2d9c55c5a48319c9a826082b755859b1b472706d (diff) | |
download | RustAndDust-3c29b80709c5885c5548a6fcaccfe35189b19b41.zip RustAndDust-3c29b80709c5885c5548a6fcaccfe35189b19b41.tar.gz |
UnitDock: optimise selected border drawing
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/hud/UnitDock.java | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java b/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java index c249c64..d2d6f91 100644 --- a/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java +++ b/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java @@ -121,6 +121,7 @@ public class UnitDock extends Bg implements Animation { int i = (int) ((scaledRect.y + scaledRect.height - y) / (scaledRect.height / units.size())); selectedUnit = units.get(i); + selected.setCenter((selectedUnit.getX() + (selectedUnit.getWidth() / 2)), (selectedUnit.getY() + (selectedUnit.getHeight() / 2))); return selectedUnit; } @@ -236,13 +237,9 @@ public class UnitDock extends Bg implements Animation Gdx.gl.glScissor((int)scissors.x, (int)scissors.y, (int)scissors.width, (int)scissors.height); super.draw(batch); - for (Unit unit : units) { - unit.draw(batch); - if (unit == selectedUnit) { - selected.setCenter((unit.getX() + (unit.getWidth() / 2)), (unit.getY() + (unit.getHeight() / 2))); - selected.draw(batch); - } - } + for (Unit unit : units) unit.draw(batch); + + if (selectedUnit != null) selected.draw(batch); batch.setTransformMatrix(saved); |