summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-04 11:28:47 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-04 11:28:47 +0100
commitbcc59be0f6af5dcab805ed0fa251bbc4bda05742 (patch)
tree8161088b9dd89152396dfd6e0fa8662dd1fdf7d9 /core
parent017dda53dd4ad0f65a761f7bb0c52021bac67958 (diff)
downloadRustAndDust-bcc59be0f6af5dcab805ed0fa251bbc4bda05742.zip
RustAndDust-bcc59be0f6af5dcab805ed0fa251bbc4bda05742.tar.gz
add game/hud/TextButton
Diffstat (limited to 'core')
-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);
+ }
+}