From 3c29b80709c5885c5548a6fcaccfe35189b19b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 23 Nov 2015 22:36:08 +0100 Subject: UnitDock: optimise selected border drawing --- core/src/ch/asynk/rustanddust/game/hud/UnitDock.java | 11 ++++------- 1 file 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); -- cgit v1.1-2-g2b99