From f71f31fc26f1e7898c3ce3a8a4bba7e9f5072106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 8 Nov 2014 12:10:00 +0100 Subject: Button: 3 states are UP/DOWN/ON --- android/assets/data/hud.atlas | 24 +++++++------- android/assets/data/hud.png | Bin 345114 -> 343848 bytes core/src/ch/asynk/tankontank/game/hud/Button.java | 38 +++++++++++----------- data/assets/hud/btn-attack-off.png | Bin 8509 -> 0 bytes data/assets/hud/btn-attack-up.png | Bin 0 -> 8509 bytes data/assets/hud/btn-cancel-off.png | Bin 8958 -> 0 bytes data/assets/hud/btn-cancel-up.png | Bin 0 -> 8958 bytes data/assets/hud/btn-check-off.png | Bin 5272 -> 0 bytes data/assets/hud/btn-check-up.png | Bin 0 -> 5272 bytes data/assets/hud/btn-move-off.png | Bin 7042 -> 0 bytes data/assets/hud/btn-move-up.png | Bin 0 -> 7042 bytes data/assets/hud/btn-promote-off.png | Bin 5381 -> 0 bytes data/assets/hud/btn-promote-up.png | Bin 0 -> 5381 bytes data/assets/hud/btn-rotate-off.png | Bin 7234 -> 0 bytes data/assets/hud/btn-rotate-up.png | Bin 0 -> 7234 bytes 15 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 data/assets/hud/btn-attack-off.png create mode 100644 data/assets/hud/btn-attack-up.png delete mode 100644 data/assets/hud/btn-cancel-off.png create mode 100644 data/assets/hud/btn-cancel-up.png delete mode 100644 data/assets/hud/btn-check-off.png create mode 100644 data/assets/hud/btn-check-up.png delete mode 100644 data/assets/hud/btn-move-off.png create mode 100644 data/assets/hud/btn-move-up.png delete mode 100644 data/assets/hud/btn-promote-off.png create mode 100644 data/assets/hud/btn-promote-up.png delete mode 100644 data/assets/hud/btn-rotate-off.png create mode 100644 data/assets/hud/btn-rotate-up.png diff --git a/android/assets/data/hud.atlas b/android/assets/data/hud.atlas index d890af5..f137d02 100644 --- a/android/assets/data/hud.atlas +++ b/android/assets/data/hud.atlas @@ -38,14 +38,14 @@ btn-attack-down orig: 60, 60 offset: 0, 0 index: -1 -btn-attack-off +btn-attack-on rotate: false xy: 778, 194 size: 60, 60 orig: 60, 60 offset: 0, 0 index: -1 -btn-attack-on +btn-attack-up rotate: false xy: 840, 194 size: 60, 60 @@ -59,14 +59,14 @@ btn-cancel-down orig: 60, 60 offset: 0, 0 index: -1 -btn-cancel-off +btn-cancel-on rotate: false xy: 254, 68 size: 60, 60 orig: 60, 60 offset: 0, 0 index: -1 -btn-cancel-on +btn-cancel-up rotate: false xy: 254, 6 size: 60, 60 @@ -80,14 +80,14 @@ btn-check-down orig: 60, 60 offset: 0, 0 index: -1 -btn-check-off +btn-check-on rotate: false xy: 316, 6 size: 60, 60 orig: 60, 60 offset: 0, 0 index: -1 -btn-check-on +btn-check-up rotate: false xy: 378, 68 size: 60, 60 @@ -101,14 +101,14 @@ btn-move-down orig: 60, 60 offset: 0, 0 index: -1 -btn-move-off +btn-move-on rotate: false xy: 440, 68 size: 60, 60 orig: 60, 60 offset: 0, 0 index: -1 -btn-move-on +btn-move-up rotate: false xy: 440, 6 size: 60, 60 @@ -122,14 +122,14 @@ btn-promote-down orig: 60, 60 offset: 0, 0 index: -1 -btn-promote-off +btn-promote-on rotate: false xy: 502, 6 size: 60, 60 orig: 60, 60 offset: 0, 0 index: -1 -btn-promote-on +btn-promote-up rotate: false xy: 564, 68 size: 60, 60 @@ -143,14 +143,14 @@ btn-rotate-down orig: 60, 60 offset: 0, 0 index: -1 -btn-rotate-off +btn-rotate-on rotate: false xy: 716, 132 size: 60, 60 orig: 60, 60 offset: 0, 0 index: -1 -btn-rotate-on +btn-rotate-up rotate: false xy: 778, 132 size: 60, 60 diff --git a/android/assets/data/hud.png b/android/assets/data/hud.png index 9d3dd4f..35f27e7 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/Button.java b/core/src/ch/asynk/tankontank/game/hud/Button.java index 4ce1120..08e2f1c 100644 --- a/core/src/ch/asynk/tankontank/game/hud/Button.java +++ b/core/src/ch/asynk/tankontank/game/hud/Button.java @@ -20,19 +20,19 @@ public class Button implements Disposable private Image image; private Rectangle rect; - private static final int OFF = 0; - private static final int ON = 1; - private static final int DOWN = 2; + private static final int UP = 0; + private static final int DOWN = 1; + private static final int ON = 2; public Button(TextureAtlas atlas, String base) { - this.idx = OFF; + this.idx = UP; this.blocked = false; this.visible = false; this.images = new Image[3]; - this.images[OFF] = new Image(atlas.findRegion(base + "-off")); - this.images[ON] = new Image(atlas.findRegion(base + "-on")); + this.images[UP] = new Image(atlas.findRegion(base + "-up")); this.images[DOWN] = new Image(atlas.findRegion(base + "-down")); + this.images[ON] = new Image(atlas.findRegion(base + "-on")); this.rect = new Rectangle(getX(), getY(), getWidth(), getHeight()); } @@ -46,18 +46,13 @@ public class Button implements Disposable public void hide() { - idx = OFF; + setUp(); visible = false; } - public void setOff() - { - idx = OFF; - } - - public void setOn() + public void setUp() { - idx = ON; + idx = UP; } public void setDown() @@ -65,21 +60,26 @@ public class Button implements Disposable idx = DOWN; } - public boolean isOn() + public void setOn() { - return (idx == ON); + idx = ON; } - public boolean isOff() + public boolean isUp() { - return (idx == OFF); + return (idx == UP); } - public boolean isDisabled() + public boolean isDown() { return (idx == DOWN); } + public boolean isOn() + { + return (idx == ON); + } + public Image getImage() { return images[idx]; diff --git a/data/assets/hud/btn-attack-off.png b/data/assets/hud/btn-attack-off.png deleted file mode 100644 index 5a29edc..0000000 Binary files a/data/assets/hud/btn-attack-off.png and /dev/null differ diff --git a/data/assets/hud/btn-attack-up.png b/data/assets/hud/btn-attack-up.png new file mode 100644 index 0000000..5a29edc Binary files /dev/null and b/data/assets/hud/btn-attack-up.png differ diff --git a/data/assets/hud/btn-cancel-off.png b/data/assets/hud/btn-cancel-off.png deleted file mode 100644 index 800c983..0000000 Binary files a/data/assets/hud/btn-cancel-off.png and /dev/null differ diff --git a/data/assets/hud/btn-cancel-up.png b/data/assets/hud/btn-cancel-up.png new file mode 100644 index 0000000..800c983 Binary files /dev/null and b/data/assets/hud/btn-cancel-up.png differ diff --git a/data/assets/hud/btn-check-off.png b/data/assets/hud/btn-check-off.png deleted file mode 100644 index 4fb965b..0000000 Binary files a/data/assets/hud/btn-check-off.png and /dev/null differ diff --git a/data/assets/hud/btn-check-up.png b/data/assets/hud/btn-check-up.png new file mode 100644 index 0000000..4fb965b Binary files /dev/null and b/data/assets/hud/btn-check-up.png differ diff --git a/data/assets/hud/btn-move-off.png b/data/assets/hud/btn-move-off.png deleted file mode 100644 index f637991..0000000 Binary files a/data/assets/hud/btn-move-off.png and /dev/null differ diff --git a/data/assets/hud/btn-move-up.png b/data/assets/hud/btn-move-up.png new file mode 100644 index 0000000..f637991 Binary files /dev/null and b/data/assets/hud/btn-move-up.png differ diff --git a/data/assets/hud/btn-promote-off.png b/data/assets/hud/btn-promote-off.png deleted file mode 100644 index 67d7cca..0000000 Binary files a/data/assets/hud/btn-promote-off.png and /dev/null differ diff --git a/data/assets/hud/btn-promote-up.png b/data/assets/hud/btn-promote-up.png new file mode 100644 index 0000000..67d7cca Binary files /dev/null and b/data/assets/hud/btn-promote-up.png differ diff --git a/data/assets/hud/btn-rotate-off.png b/data/assets/hud/btn-rotate-off.png deleted file mode 100644 index f5467b2..0000000 Binary files a/data/assets/hud/btn-rotate-off.png and /dev/null differ diff --git a/data/assets/hud/btn-rotate-up.png b/data/assets/hud/btn-rotate-up.png new file mode 100644 index 0000000..f5467b2 Binary files /dev/null and b/data/assets/hud/btn-rotate-up.png differ -- cgit v1.1-2-g2b99