diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-08 11:24:28 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-08 11:24:28 +0200 |
commit | cc1630d6571a107f6d6edd7b9e57fe6eb8d4996b (patch) | |
tree | 211c1854d2cc87fc99ec196df0cb670e33ca85f0 /core/src/ch/asynk | |
parent | 0bcbf473a5ffc5bbfc1356f7a15ae90f98f57bc2 (diff) | |
download | RustAndDust-cc1630d6571a107f6d6edd7b9e57fe6eb8d4996b.zip RustAndDust-cc1630d6571a107f6d6edd7b9e57fe6eb8d4996b.tar.gz |
Hud.Button: clean up
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index 02e7211..4d8639d 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -16,7 +16,7 @@ import ch.asynk.tankontank.TankOnTank; class Button implements Disposable { - int idx; + public int idx; private Image images []; private Image image; @@ -33,6 +33,13 @@ class Button implements Disposable this.images[DISABLED] = new Image(atlas.findRegion(base + "-disabled")); } + @Override + public void dispose() + { + for (Image image : images) + image.dispose(); + } + public void setOff() { idx = OFF; @@ -48,9 +55,14 @@ class Button implements Disposable idx = DISABLED; } - public Image getImage() + public boolean isOn() { - return images[idx]; + return (idx == ON); + } + + public boolean isOff() + { + return (idx == OFF); } public boolean isDisabled() @@ -58,24 +70,20 @@ class Button implements Disposable return (idx == DISABLED); } - public void setPosition(float x, float y) + public Image getImage() { - images[OFF].setPosition(x, y); - images[ON].setPosition(x, y); - images[DISABLED].setPosition(x, y); + return images[idx]; } - public boolean hit(float x, float y) + public void setPosition(float x, float y) { - return ((x > images[0].getX()) && (x < images[0].getX() + images[0].getWidth()) && (y > images[0].getY()) && (y < images[0].getY() + images[0].getHeight())); + for (Image image : images) + image.setPosition(x, y); } - @Override - public void dispose() + public boolean hit(float x, float y) { - images[OFF].dispose(); - images[ON].dispose(); - images[DISABLED].dispose(); + return ((x > images[0].getX()) && (x < images[0].getX() + images[0].getWidth()) && (y > images[0].getY()) && (y < images[0].getY() + images[0].getHeight())); } public float getX() { return images[0].getX(); } |