Java - Error when creating Rectangle2D object

248 views Asked by At

I am using Shapes to check for collisions in my game. I am using the intersect method for that. But strangely getting an Error when defining on of the shapes. Eclipse is telling me that this is incorrect.

This works:

// Collision Shape
protected RectangularShape col;

col = new Ellipse2D.Double(x, y, ObjectSpriteManager.SIZE, ObjectSpriteManager.SIZE);

But this does not:

// Collision Shape
protected RectangularShape col;

col = new Rectangle2D.Double(x, y, ObjectSpriteManager.SIZE, ObjectSpriteManager.SIZE);

What confuses me is that both are Subclasses of RectangularShape

https://docs.oracle.com/javase/7/docs/api/java/awt/geom/RectangularShape.html

I am really no expert in Java so I am probably overseeing something with. Maybe some of you could help me :)

/EDIT: Here is a screenshot of the problem in Eclipse: enter image description here

/EDIT_2: I found the error thanks to David ten Hove. I imported the wrong Rectangle2D.

0

There are 0 answers