I have the following code:
+(bool)Point:(CGPoint)point isInRectangle:(CGRect)rect
{
int rectx1 = rect.origin.x;
int recty1 = rect.origin.y;
int rectx2 = rect.origin.x + rect.size.width;
int recty2 = rect.origin.y + rect.size.width;
int pointx = point.x;
int pointy = point.y;
return (pointx >= rectx1 && pointx <= rectx2) && (pointy >= recty1 && pointy <= recty2);
}
It’s supposed to detect the collision between two rectangles, but I am not getting the correct value. Could anyone help me?
I think here:
you probably meant:
But, you should know there is already a C function CGRectContainsPoint (rect, point) that does what you want. So you don’t have to write one unless you want to.