This question I'ts no exactly a fix for the current game I'm working on, but I am showing it as an example to explain my problem. I just want to know the best way to handle collision in JavaFX.
My problem is that I cant seem to make collision work with javaFX using the .intercept()
function. the way I'm doing it is making a Pane that has the image and different overlapping rectangles that make the collision box. then i add this pane to another pane(the game world). then when I try to get the collision boxes that i want to compare and use .intercept()
function it doesn't work, they seem to always collide no matter what, I am using .setLayoutX
and Y to move my pane(the ship pane) if that matters and yes I am using .getBoundsOnParent()
The only way i have found that kind of works is comparing the panes themselves but that doesn't work since it just tries to compare the fills.
This is my ship:
This is my Collision Box:
Here is colliding by using the whole pane(see it doesn't work)