-
Notifications
You must be signed in to change notification settings - Fork 0
/
Button.pde
54 lines (47 loc) · 1.18 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
47
48
49
50
51
52
53
//ボタンクラス
public class Button {
private int x, y;
private int wid = 100, hei = 100;
private final String comand;
private final color c;
private boolean life = true;
public Button(int x, int y, String comand, String colorName) {
this.comand = comand;
c = setColors(colorName);
this.x = x;
this.y = y;
}
//ボタンの色の定義ここでボタンの色を増やす
private color setColors(String s) {
if (s.equals("red")) return color(255, 0, 0);
if (s.equals("blue")) return color(0, 0, 255);
if (s.equals("green")) return color(0, 255, 0);
if (s.equals("yellow")) return color(255, 255, 0);
if (s.equals("purple")) return color(255, 0, 255);
if (s.equals("cian"))return color(0, 255, 255);
return color(0, 0, 0);
}
public void draw() {
if (life) {
fill(c);
rect(x, y, wid, hei);
}
}
//ボタンの上に
public boolean onButton(int mx, int my) {
if (mx > x && mx < x + wid) {
if (my > y && my < y + hei) {
return true;
}
}
return false;
}
//ボタンを消す
public void kill() {
x = -1;
y = -1;
wid = 0;
hei = 1;
life = false;
}
}