From 7b848874f3154bd55d165cd78e5619476a14ebb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 7 Oct 2014 23:15:40 +0200 Subject: Hud: add ON OFF DISABLED constants --- core/src/ch/asynk/tankontank/game/Hud.java | 35 +++++++++++++++++++----------- 1 file 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(); } -- cgit v1.1-2-g2b99