我正在使用gamecenter編寫一個基於回合的iOS遊戲,並且遇到問題時發現目前所有人都坐在部分填充的遊戲中。我應該如何穿過我的比賽的參與者陣列並拉出坐着的球員?任何時候在遊戲中都會有[1,8]個玩家,而我正試圖用那些已經填滿的遊戲填充大廳。如何在iOS Gamecenter match.participants中查找填充席位?
2
A
回答
1
2
這裏有兩個方便的方法我寫了一個「GKTurnBasedMatch」類別:
@implementation GKTurnBasedMatch (Convenience)
- (NSArray *) remainingPlayingParticipants;
{
NSMutableArray *participants = [NSMutableArray array];
// start searching at the current player
NSUInteger currentIndex = [self.participants indexOfObject:self.currentParticipant];
for (int i = 0; i < [self.participants count]; i++)
{
GKTurnBasedParticipant *part = [self.participants objectAtIndex:(currentIndex + 1 + i)
% self.participants.count];
if (part.matchOutcome == GKTurnBasedMatchOutcomeNone)
{
[participants addObject:part];
}
}
return [NSArray arrayWithArray:participants];
}
- (NSArray *) remainingPlayingAndMatchedOpponents;
{
NSMutableArray *participants = [NSMutableArray array];
GKTurnBasedParticipant *localParticipant = [self localParticipant];
// start searching at the current player
NSUInteger currentIndex = [self.participants indexOfObject:self.currentParticipant];
for (int i = 0; i < [self.participants count]; i++)
{
GKTurnBasedParticipant *part = [self.participants objectAtIndex:(currentIndex + 1 + i)
% self.participants.count];
if (part.matchOutcome == GKTurnBasedMatchOutcomeNone
&& part.status == GKTurnBasedParticipantStatusActive
&& part != localParticipant)
{
[participants addObject:part];
}
}
return [NSArray arrayWithArray:participants];
}
@end
相關問題
- 1. 如何在sql中填充查找表?
- 2. 如何在R中查找並填充(如在Excel中)?
- 3. 在iOS上的圖像中查找非透明填充的CGRect
- 4. iOS - 如何填充UIPickerView?
- 5. iOS Gamecenter Programmatic Matchmaking
- 6. 如何在查詢中填充SQL
- 7. 如何在測試(Rails)中填充查找表
- 8. 如何自動填充查找取決於在Dynamic CRM中選擇的查找?
- 9. 何處/何時填充查找值?
- 10. 在R中填充水位
- 11. iOS GameCenter GKErrorCanceled
- 12. 如何用中位數填充NA?
- 13. 在填充貓鼬後查找
- 14. 如何填充上查看
- 15. Simulink中的位填充塊?
- 16. 如何在iOS 5中創建位置自動填充輸入字段?
- 17. UILabel iOS中的填充Swift
- 18. 模仿iOS GameCenter UI?
- 19. IOS GameCenter SandBox模式?
- 20. 如何在谷歌地圖iOS中查找當前位置?
- 21. 如何在填充
- 22. 如何查找未在iOS
- 23. iOS Facebook API - 如何填充UIWebView
- 24. ios:如何從.plist文件填充mapview
- 25. 填充在查詢
- 26. c#位圖填充
- 27. 如何找出數據庫表的填充位置?
- 28. 網絡 - 位填充
- 29. 填充「查找表」與隨機值
- 30. 在iOS中填充Tableview單元格6
我不得不說,我不知道你爲什麼被否決/投票決定關閉。這個問題對我來說似乎很合理,可惜我沒有足夠的經驗來回答Gamecenter的回答。你可能想要添加一些示例代碼或其他東西。 – 2013-05-10 04:36:48
謝謝。我不知道他們爲什麼會低估這一點。這真的令人沮喪。我似乎無法可靠地確定我的遊戲中究竟有誰。 – 2013-05-10 04:39:53
@LoganShire請參閱編輯 – 2013-05-10 06:17:33