質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,9 +18,79 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
+
**__追記__**
|
22
|
+
|
21
23
|
```ここに言語を入力
|
22
24
|
|
23
|
-
|
25
|
+
if (rectCheck.intersects(rect_ball, rect_block)) {
return true;}
|
26
|
+
|
27
|
+
```
|
28
|
+
|
29
|
+
の rect_block部分にエラーが出ています。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
forループの中のrect_block が never used となっています。
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
**警告内容**
|
40
|
+
|
41
|
+
・cannot resolve symbol rect_block
|
42
|
+
|
43
|
+
collideWidth2のローカル変数 rect_blockを作れ
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
・RectF rect_block = null; としてrect_blockをforループの外に出せ
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
・rect_block を Blockクラスのフィールド変数にせよ
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
といった警告がでます。
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
```ここに言語を入力
|
60
|
+
|
61
|
+
public class Block {
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
float x; // ブロックのx座標
|
66
|
+
|
67
|
+
float y; // ブロックのy座標
|
68
|
+
|
69
|
+
int width =40;
|
70
|
+
|
71
|
+
int height=10; // ブロックの幅、高さ
|
72
|
+
|
73
|
+
int margin = 5; //ブロックの間のマージン
|
74
|
+
|
75
|
+
final int NUM_BLOCK = 8;
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
//コンストラクタ
|
80
|
+
|
81
|
+
public Block (int _x,int _y){
|
82
|
+
|
83
|
+
this.x = (float)_x;
|
84
|
+
|
85
|
+
this.y = (float)_y;
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
public boolean collideWieth2(int view_w, int view_h, Ball _ball,Block[] _block, Block[] _block2, Block[] _block3, Block[] _block4, Block[] _block5, Block[] _block6, Block[] _block7, Block[] _block8, Block[] _block9, Block[] _block10) {
|
24
94
|
|
25
95
|
RectF rectCheck = new RectF();//判定用
|
26
96
|
|
@@ -90,9 +160,29 @@
|
|
90
160
|
|
91
161
|
|
92
162
|
|
163
|
+
|
164
|
+
|
165
|
+
if (rectCheck.intersects(rect_ball,rect_block)) { return true; }
|
166
|
+
|
93
|
-
|
167
|
+
else if (rectCheck.intersects(rect_ball,rect_block2)) { return true;}
|
168
|
+
|
94
|
-
|
169
|
+
else if (rectCheck.intersects(rect_ball,rect_block3)) { return true;}
|
170
|
+
|
95
|
-
|
171
|
+
else if (rectCheck.intersects(rect_ball,rect_block4)) { return true;}
|
172
|
+
|
173
|
+
else if (rectCheck.intersects(rect_ball,rect_block5)) { return true;}
|
174
|
+
|
175
|
+
else if (rectCheck.intersects(rect_ball,rect_block6)) { return true;}
|
176
|
+
|
177
|
+
else if (rectCheck.intersects(rect_ball,rect_block7)) { return true;}
|
178
|
+
|
179
|
+
else if (rectCheck.intersects(rect_ball,rect_block8)) { return true;}
|
180
|
+
|
181
|
+
else if (rectCheck.intersects(rect_ball,rect_block9)) { return true;}
|
182
|
+
|
183
|
+
else if (rectCheck.intersects(rect_ball,rect_block10)) { return true;}
|
184
|
+
|
185
|
+
else {return false;}
|
96
186
|
|
97
187
|
|
98
188
|
|
@@ -102,4 +192,12 @@
|
|
102
192
|
|
103
193
|
}
|
104
194
|
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
105
203
|
```
|