質問するログイン新規登録

質問編集履歴

1

追記

2016/05/20 09:04

投稿

masaakitsuyoshi
masaakitsuyoshi

スコア102

title CHANGED
File without changes
body CHANGED
@@ -8,8 +8,43 @@
8
8
 
9
9
  どうなおせばよいでしょうか。
10
10
 
11
+ **__追記__**
11
12
  ```ここに言語を入力
12
- 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) {
 return true;}
13
+ if (rectCheck.intersects(rect_ball, rect_block)) {
 return true;}
14
+ ```
15
+ の rect_block部分にエラーが出ています。
16
+
17
+ forループの中のrect_block が never used となっています。
18
+
19
+
20
+ **警告内容**
21
+ ・cannot resolve symbol rect_block
22
+ collideWidth2のローカル変数 rect_blockを作れ
23
+
24
+ ・RectF rect_block = null; としてrect_blockをforループの外に出せ
25
+
26
+ ・rect_block を Blockクラスのフィールド変数にせよ
27
+
28
+ といった警告がでます。
29
+
30
+ ```ここに言語を入力
31
+ public class Block {
32
+
33
+ float x; // ブロックのx座標
34
+ float y; // ブロックのy座標
35
+ int width =40;
36
+ int height=10; // ブロックの幅、高さ
37
+ int margin = 5; //ブロックの間のマージン
38
+ final int NUM_BLOCK = 8;
39
+
40
+ //コンストラクタ
41
+ public Block (int _x,int _y){
42
+ this.x = (float)_x;
43
+ this.y = (float)_y;
44
+ }
45
+
46
+
47
+ 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) {
13
48
  RectF rectCheck = new RectF();//判定用
14
49
  RectF rect_ball = new RectF(_ball.x - _ball.size, _ball.y - _ball.size, _ball.x + _ball.size, _ball.y + _ball.size);//当たり判定用のrect ball
15
50
 
@@ -44,10 +79,24 @@
44
79
 
45
80
  }
46
81
 
47
- return rectCheck.intersects(rect_ball,rect_block);
48
82
 
83
+ if (rectCheck.intersects(rect_ball,rect_block)) { return true; }
84
+ else if (rectCheck.intersects(rect_ball,rect_block2)) { return true;}
85
+ else if (rectCheck.intersects(rect_ball,rect_block3)) { return true;}
86
+ else if (rectCheck.intersects(rect_ball,rect_block4)) { return true;}
87
+ else if (rectCheck.intersects(rect_ball,rect_block5)) { return true;}
88
+ else if (rectCheck.intersects(rect_ball,rect_block6)) { return true;}
89
+ else if (rectCheck.intersects(rect_ball,rect_block7)) { return true;}
90
+ else if (rectCheck.intersects(rect_ball,rect_block8)) { return true;}
91
+ else if (rectCheck.intersects(rect_ball,rect_block9)) { return true;}
92
+ else if (rectCheck.intersects(rect_ball,rect_block10)) { return true;}
93
+ else {return false;}
49
94
 
50
95
 
51
96
 
52
97
  }
98
+
99
+
100
+ }
101
+
53
102
  ```