碰撞后游戏不会返回主菜单

时间:2014-06-20 22:09:01

标签: objective-c xcode

当对象在屏幕上移动时,我正在进行碰撞游戏,但由于某种原因,当对象发生碰撞时,它不会返回主菜单。它看起来很好。这有什么不对?

-(void)Crash {

if (CGRectIntersectsRect(StealthBomber.frame, LargeObstacle1.frame)) {
    [self EndGame];
}

if (CGRectIntersectsRect(StealthBomber.frame, MediumObstacle1.frame)) {
    [self EndGame];
}

if (CGRectIntersectsRect(StealthBomber.frame, SmallObstacle1.frame)) {
    [self EndGame];
}

if (CGRectIntersectsRect(StealthBomber.frame, Grass.frame)) {
    [self EndGame];
}

if (CGRectIntersectsRect(StealthBomber.frame, Dirt.frame)) {
    [self EndGame];
}

}

- (void)EndGame {

StealthBomber.hidden = YES;
[timer invalidate];

[self performSelector:@selector(NewGame) withObject:nil afterDelay:5];

}

- (无效)NewGame {

LargeObstacle1.hidden = NO;
MediumObstacle1.hidden = NO;
SmallObstacle1.hidden = NO;

StealthBomber.hidden = NO;
StealthBomber.center = CGPointMake(32, 92);
StealthBomber.image = [UIImage imageNamed:@"stealthbomber.png"];

startGame = YES;

}

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。这是一个在调用newGame时不显示隐藏项目和隐藏其他项目的问题。