我试图在基于回合的游戏中实现一个事件监听器,这样玩家就可以在轮到他或他被朋友邀请时接收。GKTurnBasedEventHandler 在 IOS 7 中已弃用,我在文档中读到我应该使用 GKLocalPlayerListener;但这就是它的延伸。有没有人用过,因为到处都没有信息。
这是我之前尝试过的,它不起作用。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer authenticateWithCompletionHandler:^(NSError *error)
{
if (localPlayer.isAuthenticated)
{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer registerListener:self];
}
}];
return YES;
}
-(void)handleInviteFromGameCenter:(NSArray *)playersToInvite
{
NSLog(@"test");
}
- (void)player:(GKPlayer *)player receivedTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive:(BOOL)didBecomeActive
{
NSLog(@"test");
}