This is the code that I have to detect when two ImageViews collide in Android:
Rect rc1 = new Rect();
brickimg.getDrawingRect(rc1);
Rect rc2 = new Rect();
playerimage.getDrawingRect(rc2);
if (Rect.intersects(rc1, rc2)) {
// intersection is detected
// here is your method call
button.setText("Shrekt m9");
}
Rect rc3 = new Rect();
brickimg2.getDrawingRect(rc3);
Rect rc4 = new Rect();
playerimage2.getDrawingRect(rc3);
if (Rect.intersects(rc3, rc4)) {
// intersection is detected
// here is your method call
button.setText("this works");
}
if(Rect.intersects(rc2, rc3)){
button.setText("this works too");
}
When I run the app, it doesn't detect anything. Am I doing something wrong?