forked from TrevorAPCS/AsteroidsGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.pde
46 lines (46 loc) · 1.04 KB
/
Button.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
class Button{
private int x, y, sX, sY, tSize;
private String bText;
public Button(int pX, int pY, int sizeX, int sizeY, String buttonText){
x = pX;
y = pY;
sX = sizeX;
sY = sizeY;
bText = buttonText;
tSize = 15;
}
public Button(int pX, int pY, int sizeX, int sizeY, String buttonText, int ts){
x = pX;
y = pY;
sX = sizeX;
sY = sizeY;
bText = buttonText;
tSize = ts;
}
public boolean checkClick(){
if(mouseX >= x && mouseX <= x + sX && mouseY >= y && mouseY <= y + sY){
return true;
}
else{
return false;
}
}
public void show(){
textAlign(CENTER);
textSize(tSize);
if(mouseX >= x && mouseX <= x + sX && mouseY >= y && mouseY <= y + sY){
fill(#0C9CE8);
noStroke();
rect(x, y, sX, sY);
fill(0);
text(bText, x + sX/2, y + sY/(1.5));
}
else{
fill(100);
noStroke();
rect(x, y, sX, sY);
fill(#0C9CE8);
text(bText, x + sX/2, y + sY/(1.5));
}
}
}