当前位置:  开发笔记 > 运维 > 正文

Gamecenter ios 9 GameCenter GKLocalPlayerListener方法未调用

如何解决《Gamecenterios9GameCenterGKLocalPlayerListener方法未调用》经验,为你挑选了1个好方法。

这是关于GameCenter.

由于"的GKLocalPlayerListener协议继承方法GKChallengeListener,GKInviteEventListenerGKTurnBasedEventListener.

为了处理多个事件"和"没有实现GKChallengeListener,GKInviteEventListenerGKTurnBasedEventListener直接; GKLocalPlayerListener而实施.

您可以使用GKLocalPlayerListener"(这些来自Apple文档)来监听和处理多个事件.

可以预期,在经过身份验证之后注册GKLocalPlayerListener之后,当适当的事件发生时,将调用其中的GKLocalPlayer.localPlayer()所有方法GKLocalPlayerListener.

但是,除了"播放器(player:GKPlayer,receivedTurnEventForMatch match:GKTurnBasedMatch,didBecomeActive:Bool)"之外,所有其他方法,包括"player(player:GKPlayer,matchEnded match :) GKTurnBasedMatch"在发生此类事件时都不会被调用.

我们需要注册一些其他听众还是我缺少一些东西?



1> Thunk..:

关于检测到您被邀请参加回合制比赛:没有发送任何活动,但是当您从服务器查询比赛列表时,您只是突然出现一个新比赛(并且您的状态将被邀请).(收件人确实得到UIAlert提示他们已收到邀请)

关于如果/当各种API函数火,我已经花了很多,很多,很多时间试图破译这些时,各种功能火灾.我打开了一些针对函数或文档的错误.这是我目前的笔记; 这就是我如何组织我的助手类中的所有委托函数,指出它们应用于哪个侦听器以及指示它们触发的原因.

你可以看到有几个我从未破译过.非常感谢此列表中的任何其他输入/说明.

#pragma mark - specific to real-time matches
//this is for real-time matches only (but the docs don't say that)
-(void)player:(GKPlayer *)player didAcceptInvite:(GKInvite *)invite



#pragma mark - saved game listener (GKSavedGameListener)
//never fires. Theory: only fires if the SAME player tries to save the game from a different device while being the active player
-(void)player:(GKPlayer *)player didModifySavedGame:(GKSavedGame *)savedGame

//never fires. Theory: only fires if the SAME player tries to save the game from a different device while being the active player
-(void)player:(GKPlayer *)player hasConflictingSavedGames:(NSArray *)savedGames



#pragma mark - game launched via game center (GKLocalPlayerListener)
//DEPRECATED: This is fired when the user asks to play with a friend from the game center.app
-(void)player:(GKPlayer *)player didRequestMatchWithPlayers:(NSArray *)playerIDsToInvite

//This is fired when the user launches the game from Game Center and requests to play with a friend
-(void)player:(GKPlayer *)player didRequestMatchWithRecipients:(NSArray *)recipientPlayers

//Never seen this fire. Possibly fired when the user launches the game from Game Center. Unclear how this varies from didRequestMatchWithRecipients
-(void)player:(GKPlayer *)player didRequestMatchWithOtherPlayers:(NSArray *)playersToInvite



#pragma mark - Ending turn based matches (GKLocalPlayerListener)
//I've never seen this fire
-(void)player:(GKPlayer *)player matchEnded:(GKTurnBasedMatch *)match

//I've never seen this fire
-(void)player:(GKPlayer *)player wantsToQuitMatch:(nonnull GKTurnBasedMatch *)match



#pragma mark - challenges (GKLocalPlayerListener)
//untested, I don't use challenges
-(void)player:(GKPlayer *)player issuedChallengeWasCompleted:(GKChallenge *)challenge byFriend:(GKPlayer *)friendPlayer

//untested, I don't use challenges
-(void)player:(GKPlayer *)player didCompleteChallenge:(GKChallenge *)challenge issuedByFriend:(GKPlayer *)friendPlayer

//untested, I don't use challenges
-(void)player:(GKPlayer *)player didReceiveChallenge:(GKChallenge *)challenge

//untested, I don't use challenges
-(void)player:(GKPlayer *)player wantsToPlayChallenge:(GKChallenge *)challenge



#pragma mark - exchanges (GKLocalPlayerListener)
//seems to work as expected
-(void)player:(GKPlayer *)player receivedExchangeCancellation:(GKTurnBasedExchange *)exchange forMatch:(GKTurnBasedMatch *)match

//this fires for the Current Player AND the Exchange Initiator AFTER all replies/timeouts are complete.
-(void)player:(GKPlayer *)player receivedExchangeReplies:(NSArray *)replies forCompletedExchange:(GKTurnBasedExchange *)exchange forMatch:(GKTurnBasedMatch *)match

//seems to work as expected
-(void)player:(GKPlayer *)player receivedExchangeRequest:(GKTurnBasedExchange *)exchange forMatch:(GKTurnBasedMatch *)match



#pragma mark - event handler (GKLocalPlayerListener)
-(void)player:(GKPlayer *)player receivedTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive:(BOOL)didBecomeActive
/*
    Apple says this fires when:
    1. When it becomes the active player's turn, including the inviting player creating a new match (CHECK)
    2. When the time out is about to fire (FAIL. It fires AFTER the timeout expires, which may just be item #4 happening)
    3. Player accepts an invite from another player (FAIL. Never happens. Instead it fires when an INVITED player starts playing a session FROM this player.)
    4. Turn was passed to another player. (CHECK)
    5. player receives a reminder (CHECK, confirmed by ?4??05)

    It Also fires when:
    6. A remote user quits (CHECK)
    7. A remote user declines (unconfirmed)
    8. An automatch player joins the game (CHECK)
    9. An invited player starts playing (CHECK)
    10. A remote user saves the game (CHECK)
*/

编辑:根据μ4ρκ05的反馈更新"提醒"通知的状态.

推荐阅读
罗文彬2502852027
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有