title: How to achieved collision detection in Translate Transition (in JavaFX)?
body: <p>I have written the below JavaFX program in which two rectangle nodes are in translate transition:</p>
  
  <pre><code>public class Test extends Application{
  public static void main(String[] args) {
      launch(args);
  }
  
  @Override
  public void start(Stage primaryStage) throws Exception {
      BorderPane borderPane = new BorderPane();
      borderPane.setStyle("-fx-background-color: green;");
  
  
      Rectangle rect1 = new Rectangle(20,20,50, 50);
      rect1.setArcHeight(15);
      rect1.setArcWidth(15);
      rect1.setFill(Color.RED);
  
      Rectangle rect2 = new Rectangle(20,20,30, 30);
      rect2.setArcHeight(15);
      rect2.setArcWidth(15);
      rect2.setFill(Color.RED);
  
      TranslateTransition translateTransition1 = new TranslateTransition(Duration.millis(2000), rect1);
      translateTransition1.setFromX(0);
      translateTransition1.setToX(300);
      translateTransition1.setToY(300);
      translateTransition1.setCycleCount(Timeline.INDEFINITE);
      translateTransition1.setAutoReverse(true);
      translateTransition1.play();
  
     TranslateTransition translateTransition2 = new TranslateTransition(Duration.millis(2000), rect2);
     translateTransition2.setFromX(300);
     translateTransition2.setToX(0);
     translateTransition2.setToY(300);
     translateTransition2.setCycleCount(Timeline.INDEFINITE);
     translateTransition2.setAutoReverse(true);
     translateTransition2.play();
  
  
      borderPane.getChildren().add(rect1);
      borderPane.getChildren().add(rect2);
  
      primaryStage.setScene(new Scene(borderPane, 500, 500));
      primaryStage.show();
  
    }
  
  }
  </code></pre>
  
  <p>How can I implement collision detection of the two rectangle nodes which are in Translate Transition?</p>