summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/ui/LabelImage.java
blob: 4f2892499eed85251ec60d57221d0c23686f1004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package ch.asynk.tankontank.ui;

import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;

public class LabelImage extends Bg
{
    private Label label;

    public LabelImage(TextureRegion region, BitmapFont font)
    {
        this(region, font, 0f);
    }

    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, position);
    }

    @Override
    public void dispose()
    {
        label.dispose();
    }

    @Override
    public void translate(float dx, float dy)
    {
        super.translate(dx, dy);
        label.translate(dx, dy);
    }

    public void setPosition(float x, float y)
    {
        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);
    }

    @Override
    public void draw(Batch batch)
    {
        if (!visible) return;
        super.draw(batch);
        label.draw(batch);
    }

    @Override
    public void drawDebug(ShapeRenderer shapes)
    {
        if (!visible) return;
        super.drawDebug(shapes);
        label.drawDebug(shapes);
    }
}