-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextObject.pde
55 lines (47 loc) · 1.18 KB
/
textObject.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
class TextObject extends GameObject {
private String text;
private boolean displayText;
private int millisAtLastShow;
private int millisToShow;
private boolean singleUse;
public TextObject(String identifier, float x, float y, String gameObjectImageFile, String text, int millisToShow) {
super(identifier, x, y, gameObjectImageFile);
this.text = text;
displayText = false;
millisAtLastShow = 0;
this.millisToShow = millisToShow;
singleUse = false;
}
public void draw() {
super.draw();
if (displayText && millis() - millisAtLastShow >= millisToShow) {
hide();
if (singleUse) {
sceneManager.getCurrentScene().removeGameObject(this);
}
}
if (displayText) {
changeFontSize(48);
drawTextInRect(text, x, y);
}
}
public void show() {
millisAtLastShow = millis();
displayText = true;
}
public void hide() {
displayText = false;
}
public void markForDeletion() {
singleUse = true;
}
public boolean mouseClicked() {
displayText = false;
if (super.mouseClicked()) {
displayText = true;
millisAtLastShow = millis();
return true;
}
return false;
}
}