You can Detect Collision between two images by making rect for those image views.
Consider my image-views being named: img_view1
and img_view2
.
Image-views creation:
//For img_view1 rect
//parameters are x,y,width,height
CGRect image_rect1 = CGRectMake(img_view1.position.x,img_view1.position.y,100,100);
//For img_view2 rect
//parameters are x,y,width,height
CGRect image_rect2 = CGRectMake(img_view2.position.x,img_view2.position.y,100,100);
Collision detection:
if(CGRectIntersectsRect(image_rect1, image_rect2))
{
NSLog(@"Rect is Intersecting");
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…