Im making a Galaga-like game and cant seem to get collision detection between a moving bullet and a rectangle (the rectangle is going to be an enemy but its just for testing). I was reading the documentation and found interpolate(double frac)
.
"While a Transition is running, this method is called in every frame. The parameter defines the current position with the animation."
So this seems like it would work but I don't how to use it. I found a good method to actually detect collisions but I don't know how to make it work during an animation.
Rectangle s1 = new Rectangle(200,5,25,25);
Rectangle bullet = new Rectangle(12,15);
PathTransition shot = new PathTransition(Duration.millis(8000),new
Line(ship.getX(),ship.getY(),ship.getX(),-15),bullet);
shot.setCycleCount(1);
shot.setRate(2);
getChildren().add(bullet);
shot.play();
///////////////////////
if(bullet.getBoundsInParent().intersects(s1.getBoundsInParent()))