After looking at some of the answers to some questions, I've realized that the Rect class could help me in determining a collision between two ImageView objects that are animated with object animators. I've created the Rect objects inside a while loop which runs inside the run() method of a runnable. After the views overlap each other nothing happens. Here's some code:
//inside run() method of anonymous inner thread class
Rect r = new Rect(all details here, such as: view1.getLeft, view1.getTop and so on);
Rect rr = new Rect(all details here, such as: view2.getLeft, view2.getTop and so on);
//further down in the loop I have this
if(r.interset(rr){
Log.d("collision", "it just happened");
}
Perhaps, I should try another method. Recently, I have been trying to calculate the distance between the views from their top left coordinates with the distance formula. The Logs show that numerical calculations are taking place but there's no message being sent to my Handler object verifying that the distance between the views is actually less than the double 10.0 . Please, if you have any advice it would be great. Like i said, I've looked at other posts but cant seem to find an answer.
Aucun commentaire:
Enregistrer un commentaire