From d3a8eb97addddafca2973c772b1ca0872c4fc79b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 16 Oct 2014 19:38:36 +0200 Subject: Msg: add write(String, float) --- core/src/ch/asynk/tankontank/game/hud/Msg.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/ch/asynk/tankontank/game/hud/Msg.java b/core/src/ch/asynk/tankontank/game/hud/Msg.java index c5b72b5..6aaff52 100644 --- a/core/src/ch/asynk/tankontank/game/hud/Msg.java +++ b/core/src/ch/asynk/tankontank/game/hud/Msg.java @@ -1,5 +1,6 @@ package ch.asynk.tankontank.game.hud; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.TextureRegion; @@ -22,6 +23,12 @@ public class Msg extends Bg this.font = font; } + public void write(String text, float duration) + { + TextBounds b = font.getBounds(text); + write(text, ((Gdx.graphics.getWidth() - b.width) / 2), ((Gdx.graphics.getHeight() - b.height) / 2), duration, 10); + } + public void write(String text, float x, float y, float duration, int padding) { this.text = text; -- cgit v1.1-2-g2b99