summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-04 11:22:04 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-04 11:22:04 +0100
commit4d310a200979310767715231126913068b49ac3b (patch)
tree64da6f69b9ccc6d04f4a426113f64b14fedcf755 /core/src
parent556f3e0d54f3489380d48538645e6b392bf4a47e (diff)
downloadRustAndDust-4d310a200979310767715231126913068b49ac3b.zip
RustAndDust-4d310a200979310767715231126913068b49ac3b.tar.gz
add game/hud/TextImage
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/TextImage.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/TextImage.java b/core/src/ch/asynk/tankontank/game/hud/TextImage.java
new file mode 100644
index 0000000..f16f992
--- /dev/null
+++ b/core/src/ch/asynk/tankontank/game/hud/TextImage.java
@@ -0,0 +1,49 @@
+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.TextureRegion;
+
+import ch.asynk.tankontank.engine.gfx.Image;
+
+public class TextImage extends Image
+{
+ private Text text;
+
+ public TextImage(TextureRegion region, BitmapFont font, String text)
+ {
+ super(region);
+ 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);
+ }
+}