Check out example codes for "javafx detect collision". It will help you in understanding the concepts better.

Code Example 1

if(rectangle1.getBoundsInParent.intersects(rectangle2.getBoundsInParent)){

//do something

}

Learn ReactJs, React Native from akashmittal.com