Hello,
I have a lag problem when I use the function “authenticateWithCompletionHandler” to check the player status (log in Game Center or not)
If the player has logged in GC, the authenticateWithCompletionHandler shows the “welcome back, playerName”, and in this case, everything is OK!
Now, the problem is, when the player NOT log in GC, notification pops to create or use an existing account, or cancel. In this case, whenever the player choose which one, my game is going to lag.
Moreover, when the network is invaild, the lag problem happens, too.
The codes I use: (write in ViewDidLoad in appdelegate.m)
if( [self isGameCenterAvailable] ){
[self authenticateLocalUser];
}
- (void) authenticateLocalUser
{
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
if([GKLocalPlayer localPlayer].isAuthenticated){
//upload grades here
}
}];
}
-(BOOL) isGameCenterAvailable
{
// check for presence of GKLocalPlayer API
Class gcClass = (NSClassFromString(@"GKLocalPlayer"));
// check if the device is running iOS 4.1 or later
NSString *reqSysVer = @"4.1";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);
return (gcClass && osVersionSupported);
}
P.S. If I don’t call the function “authenticateWithCompletionHandler”, the game runs smoothly without any delay
The tools I use:
cocos2d for iPhone v1.0.0,
Xcode4
what can I do to solve the lag problem? thanks
Thanks a lot