如何检测ImageView之间的冲突

时间:2014-10-27 06:20:27

标签: ios objective-c xcode

我尝试使用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];
}

但由于某种原因,它没有工作

0 个答案:

没有答案