Search code examples
objective-cobjectcgrect

how to detect free space around object


i've got few objects in view and i want to detect if space (for ex. [myObject frame] - 5px) is free.

now i must detect when my object is clicked but how can i detect free space?

NSString *currPuzzle = [NSString stringWithFormat:@"%d", currentPuzzle];
currentObject = [puzzleArray objectForKey:currPuzzle];
currentObjectFrame = [currentObject frame];
currentObjectCenter = [currentObject center];

int left = currentObjectFrame.origin.x - 1;
int right = currentObjectFrame.origin.x + 1;
int top = currentObjectFrame.origin.y - 1;
int bottom = currentObjectFrame.origin.y + 1;

i've got no idea how solve it.

any idea?


Solution

  • ok i resolve it. i create temporary rectangle and i detect intersect with this rect. all work great.