我正在使用这个代码来尝试检测两个图像之间的碰撞,其中一个图像在动画中,但它不起作用。
[UIView animateWithDuration:5 animations:^{
bird.center = CGPointMake(bird.center.x, 600);
fallTimer = [NSTimer scheduledTimerWithTimeInterval:.001 target:self selector:@selector(check) userInfo:nil repeats:YES];
}];
-(void)check {
if (CGRectIntersectsRect(bird.frame, cat.frame)) {
NSLog(@"YES");
}
}如何检测冲突?
发布于 2013-07-19 07:14:54
你不能在动画中使用视图的边框,返回值将不准确。相反,您应该能够从视图layer中获取presentationLayer并检查其框架。
https://stackoverflow.com/questions/17734934
复制相似问题