From 3fbb77c4a770bb82a53215b8d74a071999fd4af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 3 Dec 2014 11:40:40 +0100 Subject: Engagement: use attack and defense images intsead of flags --- android/assets/data/hud.atlas | 36 ++++++++++++------ android/assets/data/hud.png | Bin 65949 -> 66514 bytes .../ch/asynk/tankontank/game/hud/Engagement.java | 42 ++++++++++----------- data/assets/hud/attack.png | Bin 0 -> 390 bytes data/assets/hud/defense.png | Bin 0 -> 271 bytes 5 files changed, 44 insertions(+), 34 deletions(-) create mode 100644 data/assets/hud/attack.png create mode 100644 data/assets/hud/defense.png diff --git a/android/assets/data/hud.atlas b/android/assets/data/hud.atlas index cec4298..c5d5f87 100644 --- a/android/assets/data/hud.atlas +++ b/android/assets/data/hud.atlas @@ -5,77 +5,91 @@ filter: Nearest,Nearest repeat: none aps rotate: false - xy: 2, 19 + xy: 2, 28 size: 48, 48 orig: 48, 48 offset: 0, 0 index: -1 +attack + rotate: false + xy: 68, 2 + size: 24, 24 + orig: 24, 24 + offset: 0, 0 + index: -1 cancel rotate: false - xy: 130, 147 + xy: 130, 156 size: 48, 48 orig: 48, 48 offset: 0, 0 index: -1 +defense + rotate: false + xy: 94, 2 + size: 24, 24 + orig: 24, 24 + offset: 0, 0 + index: -1 disabled rotate: false - xy: 84, 69 + xy: 84, 78 size: 48, 48 orig: 48, 48 offset: 0, 0 index: -1 ge-flag rotate: false - xy: 2, 69 + xy: 2, 78 size: 80, 48 orig: 80, 48 offset: 0, 0 index: -1 ok rotate: false - xy: 52, 19 + xy: 52, 28 size: 48, 48 orig: 48, 48 offset: 0, 0 index: -1 promote rotate: false - xy: 180, 147 + xy: 180, 156 size: 48, 48 orig: 48, 48 offset: 0, 0 index: -1 reinforcement rotate: false - xy: 102, 19 + xy: 102, 28 size: 48, 48 orig: 48, 48 offset: 0, 0 index: -1 reinforcement-selected rotate: false - xy: 2, 119 + xy: 2, 128 size: 126, 126 orig: 126, 126 offset: 0, 0 index: -1 stars rotate: false - xy: 2, 2 + xy: 2, 11 size: 64, 15 orig: 64, 15 offset: 0, 0 index: -1 turns rotate: false - xy: 134, 97 + xy: 134, 106 size: 48, 48 orig: 48, 48 offset: 0, 0 index: -1 us-flag rotate: false - xy: 130, 197 + xy: 130, 206 size: 80, 48 orig: 80, 48 offset: 0, 0 diff --git a/android/assets/data/hud.png b/android/assets/data/hud.png index 4d10b46..d4429e0 100644 Binary files a/android/assets/data/hud.png and b/android/assets/data/hud.png differ diff --git a/core/src/ch/asynk/tankontank/game/hud/Engagement.java b/core/src/ch/asynk/tankontank/game/hud/Engagement.java index a5d10cf..d9a9ff1 100644 --- a/core/src/ch/asynk/tankontank/game/hud/Engagement.java +++ b/core/src/ch/asynk/tankontank/game/hud/Engagement.java @@ -18,9 +18,9 @@ public class Engagement extends Bg implements Animation public float padding; private Sprite usFlag; private Sprite geFlag; - private Sprite geWinner; - private Sprite usWinner; private Sprite winner; + private Sprite attackImg; + private Sprite defenseImg; private Label attack; private Label defense; private Label attackR; @@ -34,10 +34,8 @@ public class Engagement extends Bg implements Animation super(region); usFlag = new Sprite(atlas.findRegion("us-flag")); geFlag = new Sprite(atlas.findRegion("ge-flag")); - usWinner = new Sprite(usFlag); - geWinner = new Sprite(geFlag); - usFlag.setSize(usFlag.getWidth() * (FLAG_HEIGHT / usFlag.getHeight()), FLAG_HEIGHT); - geFlag.setSize(geFlag.getWidth() * (FLAG_HEIGHT / geFlag.getHeight()), FLAG_HEIGHT); + attackImg = new Sprite(atlas.findRegion("attack")); + defenseImg = new Sprite(atlas.findRegion("defense")); this.attack = new Label(font); this.defense = new Label(font); this.attackR = new Label(font); @@ -57,16 +55,16 @@ public class Engagement extends Bg implements Animation attackR.write(String.format("= %2d", e.attack)); defenseR.write(String.format("= %2d", e.defense)); if (e.success) - winner = ((e.attacker == Army.US) ? usWinner : geWinner); + winner = ((e.attacker == Army.US) ? usFlag : geFlag); else - winner = ((e.attacker == Army.US) ? geWinner : usWinner); + winner = ((e.attacker == Army.US) ? geFlag : usFlag); float resultW = attackR.getWidth(); float w = defenseR.getWidth(); if (w > resultW) resultW = w; - float height = (okBtn.getHeight() + (2 * usFlag.getHeight()) + (4 * padding)); - float width = (usFlag.getWidth() + (2 * d1Animation.getWidth()) + attack.getWidth() + resultW + (6 * padding)); + float height = (okBtn.getHeight() + attackImg.getHeight() + defenseImg.getHeight() + (4 * padding)); + float width = (attackImg.getWidth() + (2 * d1Animation.getWidth()) + attack.getWidth() + resultW + (6 * padding)); float x = position.getX(width); float y = position.getY(height); set(x, y, width, height); @@ -77,23 +75,21 @@ public class Engagement extends Bg implements Animation x += padding; y += (okBtn.getHeight() + padding); - Sprite flag = ((e.defender == Army.US) ? usFlag : geFlag); - flag.setPosition(x, y); - x += (flag.getWidth() + padding); - y = (y + (flag.getHeight() / 2.0f) - (defense.getHeight() / 2.0f)); + defenseImg.setPosition(x, y); + x += (defenseImg.getWidth() + padding); + y = (y + (defenseImg.getHeight() / 2.0f) - (defense.getHeight() / 2.0f)); defense.setPosition(x, y); defenseR.setPosition((getX() + width - resultW- padding), y); x = getX() + padding; - y += flag.getHeight() + padding; - flag = ((flag == geFlag) ? usFlag : geFlag); - flag.setPosition(x, y); - x += (flag.getWidth() + padding); + y += defenseImg.getHeight() + padding; + attackImg.setPosition(x, y); + x += (attackImg.getWidth() + padding); d1Animation.set(e.d1, x, y); x += (d1Animation.getWidth() + padding); d2Animation.set(e.d2, x, (y)); x += (d1Animation.getWidth() + padding); - y = (y + (flag.getHeight() / 2.0f) - (attack.getHeight() / 2.0f)); + y = (y + (attackImg.getHeight() / 2.0f) - (attack.getHeight() / 2.0f)); attack.setPosition(x, y); attackR.setPosition(defenseR.getX(), y); @@ -134,13 +130,13 @@ public class Engagement extends Bg implements Animation { if (!visible) return; super.draw(batch); + attackImg.draw(batch); + d1Animation.draw(batch); + d2Animation.draw(batch); attack.draw(batch); + defenseImg.draw(batch); defense.draw(batch); defenseR.draw(batch); - geFlag.draw(batch); - usFlag.draw(batch); - d1Animation.draw(batch); - d2Animation.draw(batch); okBtn.draw(batch); if (d1Animation.isDone() && d2Animation.isDone()) { attackR.draw(batch); diff --git a/data/assets/hud/attack.png b/data/assets/hud/attack.png new file mode 100644 index 0000000..ca4766b Binary files /dev/null and b/data/assets/hud/attack.png differ diff --git a/data/assets/hud/defense.png b/data/assets/hud/defense.png new file mode 100644 index 0000000..cf6e580 Binary files /dev/null and b/data/assets/hud/defense.png differ -- cgit v1.1-2-g2b99