-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.pde
More file actions
62 lines (53 loc) · 1.01 KB
/
Copy pathButton.pde
File metadata and controls
62 lines (53 loc) · 1.01 KB
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
public abstract class Button implements GameObject
{
String text;
int x;
int y;
int boxWidth;
int boxHeight;
int fontSize = 24;
Screen targetScreen;
public Button(int x, int y, String text )
{
this.x = x;
this.y = y;
this.text = text;
//this.targetScreen = targetScreen;
calcBoxDimensions();
}
void calcBoxDimensions()
{
textFont(f, fontSize);
boxWidth = (int) textWidth(text) + 20;
boxHeight = fontSize + 16 ;
}
public void initialize()
{
}
public void update()
{
}
public void click()
{
//<>//
}
@Override
public void render(){
strokeWeight(1);
stroke(0);
rectMode(CENTER);
textAlign(CENTER);
textFont(f, fontSize);
if(mouseX<=x+boxWidth/2 && mouseX>=x-boxWidth/2 && mouseY<=y+boxHeight/2 && mouseY>=y-boxHeight/2)
{
fill(50);
}
else
{
fill(127);
}
rect(x, y, boxWidth, boxHeight);
fill(255);
text(text, x, y + 8);
}
}