How to implement GKTurnBasedMatchOutcomeCustomRange?

夙愿已清 提交于 2019-12-25 01:41:17

问题


I've looked in the Apple GameKit Programming Guide, as well as the documentation of the GKTurnBasedParticipant to try and figure out how to implement the custom range. Apple docs say:

"Optionally, it may also use an OR operation to include a custom match outcome for your specific game. Game Center does not use the custom value; it exists to allow your game to provide additional information at the end of the match. The custom value must fit in the range provided by the GKTurnBasedMatchOutcomeCustomRange constant." ....

 GKTurnBasedMatchOutcomeFourth = 9,
    GKTurnBasedMatchOutcomeCustomRange = 0x00FF0000
};
typedef NSInteger GKTurnBasedMatchOutcome;*

I am not sure what to do to make a custom value or string for the outcome of the match. Any help would be appreciated!

Thanks, Tams


回答1:


To create a custom match outcome enum, adapt the following to your purposes:

typedef enum
{
    GKTurnBasedMatchOutcomeCustom0 = 0 | GKTurnBasedMatchOutcomeCustomRange,
    GKTurnBasedMatchOutcomeCustom1 = 1 | GKTurnBasedMatchOutcomeCustomRange,
    GKTurnBasedMatchOutcomeCustom2 = 2 | GKTurnBasedMatchOutcomeCustomRange,
    ...
    GKTurnBasedMatchOutcomeCustomLast = 65536 | GKTurnBasedMatchOutcomeCustomRange
} GKTurnBasedMatchOutcome_Custom;

For example, GKTurnBasedMatchOutcomeCustom1 will be equal to 0xFF0000.

Essentially, you are allowed a maximum of 0xFFFF+1 (65536 in decimal) custom match outcome states.




回答2:


I think you need to start from 1 rather than 0. Thus:

GKTurnBasedMatchOutcomeCustom0 = 1 | GKTurnBasedMatchOutcomeCustomRange

etc

Otherwise, the match is not considered to be over if you use GKTurnBasedMatchOutcomeCustom0.

You may want to check it out for yourself.



来源:https://stackoverflow.com/questions/9103292/how-to-implement-gkturnbasedmatchoutcomecustomrange

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!