So what am trying to do is to enable the user to draw rectangles and detect collisions between rectangles.
The rectangles are added into an Array_List shapes:
ArrayList<Shape> shapes = new ArrayList<Shape>();
and for the collisions java must go through the ArrayList to detect collisions of shapes. (Any other ways to detect the collision is fine). I know that java has a ".intersects()" method for shapes but here it's more about many shapes and i don't know how to use it here.
Here is a small beginning of what i've done so far for the collisions, am ready stuck on that. Please do help?
if (currentAction == 4) {
// Create a new rectangle using x & y coordinates
aShape = drawRectangle(drawStart.x, drawStart.y,
e.getX(), e.getY());
//aShape added to the arraylist shapes
shapes.add(aShape);
for(int i=0;i<shapes.size();i++){
Shape s = shapes.get(i);
//collision detection
}
}