Gamecenter ios 9 GameCenter GKLocalPlayerListener方法未调用 [英] Gamecenter ios 9 GameCenter GKLocalPlayerListener methods not called

查看:138
本文介绍了Gamecenter ios 9 GameCenter GKLocalPlayerListener方法未调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是关于 GameCenter

由于 GKLocalPlayerListener 协议从 GKChallengeListener , GKInviteEventListener GKTurnBasedEventListener

按顺序处理多个事件和没有实现 GKChallengeListener GKInviteEventListener GKTurnBasedEventListener 直接;实现 GKLocalPlayerListener

In order to handle multiple events" and "do not implement GKChallengeListener, GKInviteEventListener, and GKTurnBasedEventListener directly; implement GKLocalPlayerListener instead.

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

You can listen for, and handle multiple events using GKLocalPlayerListener" (these are from apple docs).

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

One would expect that after registering the GKLocalPlayerListener after the GKLocalPlayer.localPlayer() has been authenticated, then all the methods in the GKLocalPlayerListener would be called, when the appropriate events happen.

但是,除了播放器(播放器: GKPlayer ,receiveTurnEventForMatch匹配: GKTurnBasedMatch ,didBecomeActive:Bool),所谓的所有其他方法,包括播放器(播放器: GKPlayer ,matchEnded匹配: GKTurnBasedMatch )当发生这样的事件时,永远不会调用它。

However, apart from "player(player: GKPlayer, receivedTurnEventForMatch match: GKTurnBasedMatch, didBecomeActive: Bool)", which is called, all the other methods, including "player(player: GKPlayer, matchEnded match: GKTurnBasedMatch)" is never called when such an event occurs.

我们是否需要注册其他一些听众,或者我有什么东西缺少?

Do we need to register some other listener or is there something I am missing?

推荐答案

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

Regarding detecting that you've been invited to a turn based match: no event is sent, but when you query your list of matches from the server, you just have a new match suddenly show up (and your status will be invited). (the recipient does get an UIAlert prompt that they've received an invite, though)

关于各种API函数是否/何时触发,我花了很多,许多 许多 小时试图在这些各种功能触发时进行解密。我已经针对函数或文档打开了多个错误。这是我目前的笔记;这就是我如何组织我的助手类中的所有委托函数,指出它们应用于哪个侦听器以及指示它们触发的原因。

Regarding if/when the various API functions fire, I have spent many, many, many hours trying to decipher when these various functions fire. I've opened more than a few bugs either against the functions or against the documentation. Here are my current notes; This is how I've organized all the delegate functions in my helper class, indicating which listener they apply to as well as notes as to what causes them to fire.

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

You can see there are several that I've never deciphered. Any additional input/clarifications on this list would be greatly appreciated.

#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的反馈。

updated the status of "reminder" notifications based on μ4ρκ05's feedback.

这篇关于Gamecenter ios 9 GameCenter GKLocalPlayerListener方法未调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆