Question

I'm doing a lot of things now when I'm learning to programing in Objective-C. I want now to check, if two object have meet. If their positions are the same. I have done this with this:

 if(CGRectIntersectsRect(picture1.frame, picture2.frame))

But that is not the best solution, because my pictures are transparent (.png), but the picture inside is smaller and the shape of picture is not a square. So there are a lot of pixels around which I don't want to be part of this picture.

Is there a way to write like picture.frame-30 or something? Or someone have a better solution?

Was it helpful?

Solution

You can make "picture.frame - 30" object like this:

CGRect rect = picture2.frame;
CGRect innerPicture2Frame = CGRectMake(rect.origin.x+30, rect.origin.y+30, rect.size.width-60, rect.size.height-60);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top