开发者

How to detect Game Center Authentication popup

I've implemented the Game Center into my game. However, one thing bothers me which is how to detect when the Game Center launches the popup to sign in. If the user is quic开发者_StackOverflow社区k with their fingers and the network is a bit slow, they are able to start a game before the popup starts, which is fine, but I want to pause the game while they sign in. I thought that the UIApplicationDelegate method - (void)applicationWillResignActive:(UIApplication *)application would be called, but this is not the case.

Is there a way to detect this and thus letting me pause the game while the user attends to the popup?


Remember that you have to implement the two following methods in order to get notified in case of changes.

Here below is my simple version..So basically you cannot start a network game, or view the ladder before being identified as the button were hidden :)

- (void) registerForAuthenticationNotification
{

    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    [nc addObserver: self
           selector:@selector(authenticationChanged)
               name:GKPlayerAuthenticationDidChangeNotificationName
             object:nil];
}
- (void) authenticationChanged
{
    if ([GKLocalPlayer localPlayer].isAuthenticated)
 {
  [networkGame setHidden:NO];
  [ladder setHidden:NO];
 }
 else
 {
  [networkGame setHidden:YES];
  [ladder setHidden:YES];
 }
}


From http://www.cocos2d-iphone.org/forum/topic/14921

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWindowDidResignActive:) name:UIWindowDidResignKeyNotification object:nil];

-(void)applicationWindowDidResignActive { [[Gamemanager sharedManager] pause];

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜