summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/TextButton.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/TextButton.java b/core/src/ch/asynk/tankontank/game/hud/TextButton.java
new file mode 100644
index 0000000..158a2b0
--- /dev/null
+++ b/core/src/ch/asynk/tankontank/game/hud/TextButton.java
@@ -0,0 +1,47 @@
+package ch.asynk.tankontank.game.hud;
+
+import com.badlogic.gdx.graphics.g2d.Batch;
+import com.badlogic.gdx.graphics.g2d.BitmapFont;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
+
+public class TextButton extends Button
+{
+ private Text text;
+
+ public TextButton(TextureAtlas atlas, String base, BitmapFont font, String text)
+ {
+ super(atlas, base);
+ this.text = new Text(font, text);
+ }
+
+ @Override
+ public void dispose()
+ {
+ super.dispose();
+ text.dispose();
+ }
+
+ public void setPosition(float x, float y)
+ {
+ super.setPosition(x, y);
+ setTextPosition((x + ((getWidth() - text.getWidth()) / 2)), (y + ((getHeight() - text.getHeight()) / 2)));
+ }
+
+ public void setTextPosition(float x, float y)
+ {
+ text.setPosition(x, y);
+ }
+
+ public void write(String text)
+ {
+ this.text.write(text);
+ }
+
+ @Override
+ public void draw(Batch batch)
+ {
+ if (!visible) return;
+ super.draw(batch);
+ text.draw(batch);
+ }
+}