diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-05 20:32:09 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-05 20:32:09 +0100 |
commit | 5c6738cef7222a242b0d40241ee1c778c61866f1 (patch) | |
tree | 9e708d90b66ecaa9195b2f676c9df29fcfad06db | |
parent | abc7023afe882398c8c1a5d15db683331f677816 (diff) | |
download | RustAndDust-5c6738cef7222a242b0d40241ee1c778c61866f1.zip RustAndDust-5c6738cef7222a242b0d40241ee1c778c61866f1.tar.gz |
UnitDock: factorise matrix and scale computation
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/hud/UnitDock.java | 14 |
1 files 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; } |