summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-12-17 16:09:49 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-12-17 16:09:49 +0100
commitc994a0f9d51a1bbb2bff20ebcb4b4a630f310ce6 (patch)
tree16a3882885a86648c559b5170958a396035ee166 /core
parent13e3cd5614e74a327ca99d5e369d566cef9507dc (diff)
downloadRustAndDust-c994a0f9d51a1bbb2bff20ebcb4b4a630f310ce6.zip
RustAndDust-c994a0f9d51a1bbb2bff20ebcb4b4a630f310ce6.tar.gz
LabelImage: add translate(), clean
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/LabelImage.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/LabelImage.java b/core/src/ch/asynk/tankontank/game/hud/LabelImage.java
index f0c9c4e..832c859 100644
--- a/core/src/ch/asynk/tankontank/game/hud/LabelImage.java
+++ b/core/src/ch/asynk/tankontank/game/hud/LabelImage.java
@@ -8,7 +8,6 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
public class LabelImage extends Bg
{
private Label label;
- public Position labelPosition;
public LabelImage(TextureRegion region, BitmapFont font)
{
@@ -17,9 +16,13 @@ public class LabelImage extends Bg
public LabelImage(TextureRegion region, BitmapFont font, float padding)
{
+ this(region, font, padding, Position.MIDDLE_CENTER);
+ }
+
+ public LabelImage(TextureRegion region, BitmapFont font, float padding, Position position)
+ {
super(region);
- this.label = new Label(font, padding);
- this.labelPosition = Position.MIDDLE_CENTER;
+ this.label = new Label(font, padding, position);
}
@Override
@@ -28,22 +31,27 @@ public class LabelImage extends Bg
label.dispose();
}
- public void setLabelPosition(Position position)
+ @Override
+ public void translate(float dx, float dy)
{
- labelPosition = position;
- setPosition(rect.x, rect.y);
+ super.translate(dx, dy);
+ label.translate(dx, dy);
}
public void setPosition(float x, float y)
{
- setPosition(x, y, getWidth(), getHeight());
- label.setPosition(labelPosition.getX(this, label.getWidth()), labelPosition.getY(this, label.getHeight()));
+ super.setPosition(x, y);
+ label.setPosition(x, y);
+ }
+
+ public void setLabelPosition(Position position)
+ {
+ label.setPosition(position, this);
}
public void write(String text)
{
this.label.write(text);
- setPosition(getX(), getY());
}
@Override