1

In my game the player uses a Rectangle for his bounding box, he can do this because I only need to rotate the player image and not the acctual rectangle but for a eletric beam that one of the bosses have I need to use a Shape because I need to rotate the acctual bounding box and not only the image. The problem is that because I have one Rectangle and one Shape I can't use rectangle.intersect(shape) nor rectangle.intersect((Rectangle)shape) so how would I be able to check the collision between the rectangle and the shape? or is there a way that I can rotate a rectangle on instead of a shape (I use the createTransformedShape instance of an AffineTransform to rotate the shape )?

  • 1
    `Rectangle` extends `Rectangle2D`. `Shape` has a method called `intersects(Rectangle2D)` - Sorry, I might be missing something, it's late and I'm overdue for my nice warm bed :P. `Rectangle` is also a `Shape`, via `Rectangle`->`Rectangle2D`->`RectangularShape`->`Shape`. `Shape` has a method called `getBounds` which can return a `Rectangle` (or `getBounds2D` for a `Rectangle2D`) – MadProgrammer May 18 '13 at 12:21
  • 1
    A `Rectangle` **is a** `Shape`. So [this source](http://stackoverflow.com/questions/14574045/image-based-collision-detection/14575043#14575043) should work. – Andrew Thompson May 18 '13 at 12:21

0 Answers0