0

ゲームにレイヤーがあります。ゲームの終了時に、ゲームを再起動または終了するための UIAlertView をユーザーに表示したいと考えています。しかし、それは機能していません。また、レイヤーへのデリゲート UIAlertViewDelegate も与えられます。

解決策はありますか?

私のコードは次のとおりです。

-(void)gameFinished{
    [[UIApplication sharedApplication] setIdleTimerDisabled:NO];

    [self unschedule:@selector(checkForCollision)];
    [self unschedule:@selector(dropObject)];
    [self stopBackgroundMusic];

    [self startNewForegroundMusic:@"GameOver" ofType:@"caf"];
    [self playForegroundMusic];

    [[Director sharedDirector] pause];
    UIAlertView *view=[[UIAlertView alloc] initWithTitle:@"Game Finished" message:@"Want to play again?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes"];
    [view show];
    [view release];
} 
4

2 に答える 2

1

コードがクラッシュしたり、表示されなかったりしますか?

行にわずかなエラーがあります

[[UIAlertView alloc] initWithTitle:@"Game Finished"
                     message:@"Want to play again?"
                     delegate:self cancelButtonTitle:@"No"
                     otherButtonTitles:@"Yes"]

これは

[[UIAlertView alloc] initWithTitle:@"Game Finished"
                     message:@"Want to play again?"
                     delegate:self cancelButtonTitle:@"No"
                     otherButtonTitles:@"Yes", Nil]

注: 最後のパラメーターは可変引数であるため、Nil で終了する必要があります。

于 2009-12-16T08:51:08.790 に答える