forked from asalga/Tetrissing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextBoxView.pde
58 lines (46 loc) · 1.03 KB
/
TextBoxView.pde
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
public class TextBoxView{
/*public final class Align{
public static final int LEFT = 0;
public static final int RIGHT = 1;
public static final int CENTER = 2;
}*/
private SpriteFont font;
private String text;
private int x, y;
private int align;
private boolean visible;
public TextBoxView(){
text = "";
x = y = 0;
visible = true;
}
public void setVisible(boolean vis){
visible = vis;
}
public void setFont(String fontPath){
font = new SpriteFont(fontPath, 14, 14, 2);
}
public void setPosition(int x, int y){
this.x = x;
this.y = y;
}
public void render(){
if(visible == false){
return;
}
if(font == null){
return;
}
pushMatrix();
translate(x, y);
for(int i = 0; i < text.length(); i++){
PImage charToPrint = font.getChar(text.charAt(i));
image(charToPrint, x, y);
x += font.getCharWidth() + 2;
}
popMatrix();
}
public void setText(String text){
this.text = text;
}
}