android - What is the most efficient way to check if two imageviews intersect? -
i working on android app have 1 fixed imageview in middle of screen , other imageviews moving towards it. implement method notify me 1 of moving images touches middle one. using right now:
public void checkloss() { if(speklist.size() > 0) { for(spek spek : speklist) { final int[] position = new int[2]; spek.getlocationinwindow(position); final rect rect1 = new rect(position[0], position[1], position[0] + spek.getwidth(), position[1] + spek.getheight()); middle.getlocationinwindow(position); final rect rect2 = new rect(position[0], position[1],position[0] + middle.getwidth(), position[1] + middle.getheight()); if(rect.intersects(rect1, rect2)) { if (health == 1) { lost = true; gameover(); break; } else { health--; setmiddleimage(health); removespek(spek); break; } } } } }
this works realized it's not accurate. more not moving images reach way middle of fixed 1 before notification, whereas happen borders touch. there sort of library offers this? , if there is, how easy implement it?
thanks support :)
Comments
Post a Comment