I am developing a game. I would probably need to do some math in it. I have a character made out of about 5-6 bitmaps together. I want to check its collisions. For example if he hits a bullet, hit platform and all of this stuff. I also want to check if a bitmap is being pressed(like a button). I heard that a rect is good for this but I'm not sure how to use it. can anyone explain how to use the rect for it or if you have a better or easier idea. Thanks!
Asked
Active
Viewed 707 times
2 Answers
0
Checkout the Playing with graphics in Adroid series of articles. Collision detection is covered specifically in part 7.

rwilliams
- 21,188
- 6
- 49
- 55
-
-
-
-
can you give me a tutorial just for the rect thing, i dont want to read all these pages, i just want to know if the player touches the rect, and if lets say rect A is colliding with rect B. thanks again – Baruch Oct 15 '11 at 17:35
0
Never mind, i found out that the rect class has contains option. for example:
Rect r = new Rect();
r.set(left, top, right, bottom);
if (r.contains(x, y)){
// this is where it will happen if you touch it
}
if (r.contains(r2)){
//what happens if it collides with rect number 2
}
//or check intersect
if(r2.intersect(r)){
//what happens if it collides with rect number 2
}

Baruch
- 1,618
- 5
- 23
- 42