我尝试使用CGRectIntersectsRect
- (void)placeLine{
randomTop = arc4random()%300;
randomTop = randomTop - 150;
randomBot = randomTop + 300;
line1.center = CGPointMake(randomTop, 000);
line2.center = CGPointMake(randomBot, 000);
if (CGRectIntersectsRect(ball.frame, line1.frame)){
[self gameOver];
}
if (CGRectIntersectsRect(ball.frame, line2.frame)){
[self gameOver];
}
}
- (void)gameOver {
self.view.backgroundColor = [UIColor blackColor];
}
但由于某种原因,它没有工作