summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-12-17 16:13:18 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-12-17 16:13:18 +0100
commitf644429d4093984d277a3c564c979af251578f26 (patch)
tree86de931919fcd8b7e09a74c61eaf6aa342b5e1b3 /core/src/ch/asynk
parent593d1f909e8f5bee21e9e4fbe42fcfebda3f4d79 (diff)
downloadRustAndDust-f644429d4093984d277a3c564c979af251578f26.zip
RustAndDust-f644429d4093984d277a3c564c979af251578f26.tar.gz
Engagement: add updatePosition()
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Engagement.java50
1 files changed, 42 insertions, 8 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/Engagement.java b/core/src/ch/asynk/tankontank/game/hud/Engagement.java
index 9180a26..6522bde 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Engagement.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Engagement.java
@@ -57,6 +57,26 @@ public class Engagement extends Patch implements Animation
this.d4Animation = new DiceAnimation();
}
+ public void updatePosition()
+ {
+ if (!visible) return;
+ float dx = (position.getX(rect.width) - rect.x);
+ float dy = (position.getY(rect.height) - rect.y);
+ translate(dx, dy);
+ winner.translate(dx, dy);
+ attackImg.translate(dx, dy);
+ defenseImg.translate(dx, dy);
+ attack.translate(dx, dy);
+ defense.translate(dx, dy);
+ attackR.translate(dx, dy);
+ defenseR.translate(dx, dy);
+ okBtn.translate(dx, dy);
+ d1Animation.translate(dx, dy);
+ d2Animation.translate(dx, dy);
+ d3Animation.translate(dx, dy);
+ d4Animation.translate(dx, dy);
+ }
+
public void show(Map.Engagement e, Position position, float volume)
{
DiceAnimation.initSound(volume);
@@ -72,6 +92,24 @@ public class Engagement extends Patch implements Animation
else
winner = ((e.attacker == Army.US) ? geFlag : usFlag);
+
+ reroll = (e.d3 != 0);
+ delay = 0f;
+ d1Animation.set(e.d1);
+ d2Animation.set(e.d2);
+ if (reroll) {
+ d3Animation.set(e.d3);
+ d4Animation.set(e.d4);
+ }
+
+ this.position = position;
+ placeElements();
+
+ visible = true;
+ }
+
+ private void placeElements()
+ {
float w = attackR.getWidth();
float w2 = defenseR.getWidth();
if (w2 > w)
@@ -99,22 +137,18 @@ public class Engagement extends Patch implements Animation
y += defenseImg.getHeight() + VSPACING;
attackImg.setPosition(x, y);
x += (attackImg.getWidth() + HSPACING);
- d1Animation.set(e.d1, x, y);
+ d1Animation.setPosition(x, y);
x += (d1Animation.getWidth() + HSPACING);
- d2Animation.set(e.d2, x, (y));
+ d2Animation.setPosition(x, (y));
x += (d1Animation.getWidth() + HSPACING);
y = (y + (attackImg.getHeight() / 2f) - (attack.getHeight() / 2f));
attack.setPosition(x, y);
attackR.setPosition(defenseR.getX(), y);
- reroll = (e.d3 != 0);
- delay = 0f;
if (reroll) {
- d3Animation.set(e.d3, x, y);
- d4Animation.set(e.d4, x, y);
+ d3Animation.setPosition(x, y);
+ d4Animation.setPosition(x, y);
}
-
- visible = true;
}
private void reroll()