1、启动GameCenter
1.1、初始化GameCenterManager
#import "GameCenterManager.h"
[GameCenterManager sharedManager] setupManagerAndSetShouldCryptWithKey:@“YourKey”];
1.2、设置GameCenter代理
@interface XGSDKImpl ()<GameCenterManagerDelegate>{
}
[[GameCenterManager sharedManager] setDelegate:self];
#pragma gamecenter delegate
//要求调用代理时,用户需要使用GameCenter登录视图控制器认证
- (void)gameCenterManager:(GameCenterManager *)manager authenticateUser:(UIViewController *)gameCenterLoginController
{
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:gameCenterLoginController animated:YES completion:nil];
}
2、获取登陆GameCenter产生的playerId
- (NSString *)getTempAccountWithGameCenter
{
BOOL available = [[GameCenterManager sharedManager] checkGameCenterAvailability];
NSString *playid = nil;
if (available) {
playid = [[GameCenterManager sharedManager] localPlayerId];
}
return [[NSString stringWithFormat:@"%@",playid] md5];
;
}
3、总结
这只是启用GameCenterManager登陆以及获取其登陆id的基本步骤,当然那GameCenterManager中还有其它许多的功能,所以附上GameCenterManager源文档.