I am using JavaFx 8 library.
My task is simple: I want to check if circle collides with a path that has a thick stroke around it. The problem is that both functions Path.intersect() and Shape.intersect() ignores the stroke around a path/line.
Path tempPath = new Path(player.getPath().getElements());
//player.getDot() is Circle
if(tempPath.intersects(player.getDot().getBoundsInParent())){
Shape intersect = Shape.intersect(tempPath, player.getDot());
if(intersect.getBoundsInLocal().getWidth() != -1){
System.out.println("Path Collision occurred");
}
}
My path is made out of many LineTo objects. The format is this:
/** Creates path and player dot */
private void createPath() {
this.path = new Path();
this.path.setStrokeWidth(20);
this.path.setStroke(Color.RED);
this.path.setStrokeLineCap(StrokeLineCap.ROUND);
this.path.setStrokeLineJoin(StrokeLineJoin.ROUND);
this.dot = new Circle(10, Color.BLUE);
this.dot.setOpacity(1);
}
How could I implement a successful collision detection?