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.