diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-07 23:15:40 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-07 23:15:40 +0200 |
commit | 7b848874f3154bd55d165cd78e5619476a14ebb8 (patch) | |
tree | 5c91a05c863ab3a407367676256b05aa2b412e67 /core/src/ch | |
parent | 5dc2888276a06f58470500e9bc3d563aa58d99ec (diff) | |
download | RustAndDust-7b848874f3154bd55d165cd78e5619476a14ebb8.zip RustAndDust-7b848874f3154bd55d165cd78e5619476a14ebb8.tar.gz |
Hud: add ON OFF DISABLED constants
Diffstat (limited to 'core/src/ch')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index 4a12da1..2943c9d 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -20,28 +20,32 @@ class Button implements Disposable private Image images []; private Image image; + private static final int OFF = 0; + private static final int ON = 1; + private static final int DISABLED = 2; + public Button(TextureAtlas atlas, String base) { - this.idx = 0; + this.idx = OFF; this.images = new Image[3]; - this.images[0] = new Image(atlas.findRegion(base + "-off")); - this.images[1] = new Image(atlas.findRegion(base + "-on")); - this.images[2] = new Image(atlas.findRegion(base + "-disabled")); + this.images[OFF] = new Image(atlas.findRegion(base + "-off")); + this.images[ON] = new Image(atlas.findRegion(base + "-on")); + this.images[DISABLED] = new Image(atlas.findRegion(base + "-disabled")); } public void setOff() { - idx = 0; + idx = OFF; } public void setOn() { - idx = 1; + idx = ON; } public void disable() { - idx = 2; + idx = DISABLED; } public Image getImage() @@ -49,11 +53,16 @@ class Button implements Disposable return images[idx]; } + public boolean isDisabled() + { + return (idx == DISABLED); + } + public void setPosition(float x, float y) { - images[0].setPosition(x, y); - images[1].setPosition(x, y); - images[2].setPosition(x, y); + images[OFF].setPosition(x, y); + images[ON].setPosition(x, y); + images[DISABLED].setPosition(x, y); } public boolean hit(float x, float y) @@ -64,9 +73,9 @@ class Button implements Disposable @Override public void dispose() { - images[0].dispose(); - images[1].dispose(); - images[2].dispose(); + images[OFF].dispose(); + images[ON].dispose(); + images[DISABLED].dispose(); } public float getX() { return images[0].getX(); } |