summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/game/Hud.java36
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(); }