Wykryj kolizję JavaFX
if(rectangle1.getBoundsInParent.intersects(rectangle2.getBoundsInParent)){
//do something
}
Jolly Jaguar
if(rectangle1.getBoundsInParent.intersects(rectangle2.getBoundsInParent)){
//do something
}
private void checkBounds(Shape block) {
boolean collisionDetected = false;
for (Shape static_bloc : nodes) {
if (static_bloc != block) {
static_bloc.setFill(Color.GREEN);
if (block.getBoundsInParent().intersects(static_bloc.getBoundsInParent())) {
collisionDetected = true;
}
}
}
if (collisionDetected) {
block.setFill(Color.BLUE);
} else {
block.setFill(Color.GREEN);
}
}