I am having 2 images and i need to collide them properly. I tried many solutions but can't collide them properly.
Here are the images
Image 1
Image 2 
I tried CGRectIntersectsRect(), but its not working properly because images are colliding before they actually meet because of frame issue. Please help me.
I tried using Sprite Kit also but dint work for me.
Edit 1 :
Tried this code but its not working or is very slow :
- (void) checkIntersectionOfRect1 :(CGRect) frame1 Rect2 : (CGRect) frame2 {
CGAffineTransform cg1 = CGAffineTransformIdentity;
CGMutablePathRef *cgPath1 = CGPathCreateWithRect(frame1,&cg1);
CGAffineTransform cg2 = CGAffineTransformIdentity;
CGMutablePathRef *cgPath2 = CGPathCreateWithRect(frame2,&cg1);
ANPathBitmap * bm1 = [[ANPathBitmap alloc] initWithPath:cgPath1];
ANPathBitmap * bm2 = [[ANPathBitmap alloc] initWithPath:cgPath2];
[bm1 generateBitmap];
[bm2 generateBitmap];
ANPathIntersection * intersection = [[ANPathIntersection alloc] initWithPathBitmap:bm1 anotherPath:bm2];
if ([intersection pathLinesIntersect:&CGPointZero]) {
NSLog(@"intersect");
[self endGame];
}
else {
NSLog(@"No intersection");
}
}
Please someone help.
Umm, Im not sure but. I checked your images, and downloaded them on my mac. They are transparent, so any space before your actual image which is transparent you cannot see and if that hits the image that will trigger the collision.
To be sure, set the background colour of your image view, to a stand out colour like blue and see where the problem happens. Then you would need to use preview and cut some space off, until it is exact to the point of the edge.
Or change the view of your image view to, Redraw. That will make your image FIT your image view. Your code looks fine to me.
Or you could use a NSTimer and set the time to 0.0001, and make a if statement.
You will know this, your code is quite complex , for you could have done it a much simpler way. If you have any questions, please ask! Thanks!