summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/game
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-11-05 20:32:09 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-11-05 20:32:09 +0100
commit5c6738cef7222a242b0d40241ee1c778c61866f1 (patch)
tree9e708d90b66ecaa9195b2f676c9df29fcfad06db /core/src/ch/asynk/rustanddust/game
parentabc7023afe882398c8c1a5d15db683331f677816 (diff)
downloadRustAndDust-5c6738cef7222a242b0d40241ee1c778c61866f1.zip
RustAndDust-5c6738cef7222a242b0d40241ee1c778c61866f1.tar.gz
UnitDock: factorise matrix and scale computation
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game')
-rw-r--r--core/src/ch/asynk/rustanddust/game/hud/UnitDock.java14
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;
}