I am making a JavaFX based game that shoots drones using a spaceship to defend your base. I want to wrap a shape around an image to create a hitbox for it.
This will allow the laser to cause damage to the drone whenever it touches the hitbox. It will make the game look better than the laser hitting an invisible wall (the shape's dimensions), and not the actual image.
My question is, is there any built-in library that JavaFX provides to solve this problem, or do you have to use a calculus formula to solve this?
I have tried to look over the API's of JavaFX, but I cannot seem to find anything useful.
// Getting the images for the shapes
Image spaceCity = new Image("com/images/spaceCity.jpg");
Image spaceShip = new Image("com/images/spaceShip.png");
// Making the graphics
Rectangle space_Ship = new Rectangle(0, positionOfShipY, 191, 300);
Rectangle background = new Rectangle(0, 0, STAGE_WIDTH, STAGE_HEIGHT);
I have my example here (I do not know why Stack overflow does not allow me to upload images):
https://docs.google.com/document/d/1A8HJ61jhthBhd7wr6xrZNLlsTcQJNLUhTzrucvNY3BY/view?usp=sharing