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
73
74
|
package ch.asynk.rustanddust.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);
this.label.setParent(this);
}
@Override
public void dispose()
{
label.dispose();
}
@Override
public void update()
{
super.update();
label.update();
}
@Override
public void setPosition(float x, float y, float w, float h)
{
rect.set(x, y, w, h);
label.update();
}
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);
}
}
|