From 5c6738cef7222a242b0d40241ee1c778c61866f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 5 Nov 2015 20:32:09 +0100 Subject: UnitDock: factorise matrix and scale computation --- core/src/ch/asynk/rustanddust/game/hud/UnitDock.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java b/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java index e101ff7..4e708c4 100644 --- a/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java +++ b/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java @@ -66,6 +66,11 @@ public class UnitDock extends Bg implements Animation for (Unit unit : units) unit.translate(_dx, _dy); to = position.getX(rect.width * SCALE); + compute(); + } + + private void compute() + { transform.idt(); transform.translate((rect.x + dx), (rect.y + rect.height), 0).scale(SCALE, SCALE, 0).translate(-rect.x, - (rect.y + rect.height), 0); point.set(rect.x, rect.y, 0).mul(transform); @@ -187,14 +192,7 @@ public class UnitDock extends Bg implements Animation } } - transform.idt(); - transform.translate((rect.x + dx), (rect.y + rect.height), 0).scale(SCALE, SCALE, 0).translate(-rect.x, - (rect.y + rect.height), 0); - point.set(rect.x, rect.y, 0).mul(transform); - scaledRect.x = point.x; - scaledRect.y = point.y; - point.set((rect.x + rect.width), (rect.y + rect.height), 0).mul(transform); - scaledRect.width = point.x - scaledRect.x; - scaledRect.height = point.y - scaledRect.y; + compute(); return false; } -- cgit v1.1-2-g2b99