I am trying to make a game for school.
In this game I simulate collision by using the .collision function of the awt.Shape 's I am using.
Now I am adding an object that is not a rectangle and I see that you can not use intersect for a comparison between different shapes.
Is there any build in way to still compare these?
Can't think of anything offhand. There are several intersects and contains methods in the GeneralPath class, but I don't know whether they are any improvement for you.
I shall move this discussion to our GUIs forum, where we usually discuss such questions.
Joined: Mar 27, 2011
Solved I used the Java 2D Shape Implementations I want to check if a Rectangle2D intersects with a Ellipse2D.Double or Ellipse2D.Float.
The intersect method I used of java.awt.Shape can only be passed a Rectangle2D Object.
But the problem is solved by calling the intersect method on the Ellipse2D and passing the Rectangle2D instead of the other way around.
If anybody could explain to me why you can not simply compare all shapes (now at least one of them has to be a Rectangle2D) I would be very thankful.
Joined: Oct 13, 2005
Well done Don't know why you can only do it that way round. Maybe if I really remember to move you to GUIs somebody there will know. [Even though they are the same people you meet here ]