summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-01 11:34:38 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-01 11:34:38 +0100
commitf982678bfd6343dde03410c246a2d07028e99481 (patch)
treea1d013901961d4cb9f4ea5430836f133909b2bb1 /core/src
parenta9f54e6e2d503f5f07c427a9fb928fca61f5d194 (diff)
downloadRustAndDust-f982678bfd6343dde03410c246a2d07028e99481.zip
RustAndDust-f982678bfd6343dde03410c246a2d07028e99481.tar.gz
Msg: use Position
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/game/Hud.java8
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Msg.java6
2 files changed, 11 insertions, 3 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java
index e4fae79..e2e0ae2 100644
--- a/core/src/ch/asynk/tankontank/game/Hud.java
+++ b/core/src/ch/asynk/tankontank/game/Hud.java
@@ -13,6 +13,7 @@ import ch.asynk.tankontank.engine.gfx.Image;
import ch.asynk.tankontank.game.hud.Bg;
import ch.asynk.tankontank.game.hud.Button;
import ch.asynk.tankontank.game.hud.Msg;
+import ch.asynk.tankontank.game.hud.Position;
import ch.asynk.tankontank.TankOnTank;
@@ -92,7 +93,12 @@ public class Hud implements Disposable
public void notify(String s)
{
- msg.write(s, 1);
+ msg.write(s, 1, Position.MIDDLE_CENTER);
+ }
+
+ public void notify(String s, Position position)
+ {
+ msg.write(s, 1, position);
}
private float setButton(Button btn, float x, float y)
diff --git a/core/src/ch/asynk/tankontank/game/hud/Msg.java b/core/src/ch/asynk/tankontank/game/hud/Msg.java
index 6aaff52..885b395 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Msg.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Msg.java
@@ -23,10 +23,12 @@ public class Msg extends Bg
this.font = font;
}
- public void write(String text, float duration)
+ public void write(String text, float duration, Position position)
{
TextBounds b = font.getBounds(text);
- write(text, ((Gdx.graphics.getWidth() - b.width) / 2), ((Gdx.graphics.getHeight() - b.height) / 2), duration, 10);
+ float w = b.width + (2 * padding);
+ float h = b.height + (2 * padding);
+ write(text, position.getX(w), position.getY(h), duration, 10);
}
public void write(String text, float x, float y, float duration, int padding)