gpt4 book ai didi

ios - Gamecenter ios 9 GameCenter GKLocalPlayerListener 方法未调用

转载 作者:搜寻专家 更新时间:2023-10-30 22:34:29 25 4
gpt4 key购买 nike

这是关于 GameCenter 的。

因为“GKLocalPlayerListener 协议(protocol)继承了GKChallengeListenerGKInviteEventListenerGKTurnBasedEventListener 的方法。

为了处理多个事件”和“不要直接实现GKChallengeListenerGKInviteEventListenerGKTurnBasedEventListener;改为实现 GKLocalPlayerListener

您可以使用 GKLocalPlayerListener 监听和处理多个事件”(这些来自苹果文档)。

GKLocalPlayer.localPlayer()认证通过后,注册GKLocalPlayerListener后,GKLocalPlayerListener中的所有方法都会发生当适当的事件发生时,将被调用。

然而,除了调用“player(player: GKPlayer, receivedTurnEventForMatch match: GKTurnBasedMatch, didBecomeActive: Bool)”,所有其他方法,包括“player(player: GKPlayer, matchEnded match: GKTurnBasedMatch)"在此类事件发生时永远不会被调用。

我们是否需要注册其他监听器,或者我是否遗漏了什么?

最佳答案

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

关于各种 API 函数是否/何时触发,我花了很多、很多很多 时间试图破译这些不同的函数何时触发火。我已经针对功能或文档打开了多个错误。这是我目前的笔记;这就是我在我的助手类中组织所有委托(delegate)函数的方式,指示它们适用于哪个监听器以及关于导致它们触发的原因的注释。

你可以看到有几个我从未破译过。对此列表的任何其他输入/说明将不胜感激。

#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 的反馈更新了“提醒”通知的状态。

关于ios - Gamecenter ios 9 GameCenter GKLocalPlayerListener 方法未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34452098/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com