Sol*_*oft 2 iphone objective-c game-center
所有
我为Apple iOS制作了一款游戏.现在我想在Apple的游戏中心展示我的好友列表.
如何在iPhone上显示登录播放器的Game Center好友列表,可能使用UIViewController(管理ViewControllers)?
任何帮助,将不胜感激..
谢谢...
要在您的应用中显示您的游戏中心朋友,您可以使用下面给出的代码.
-(void) retrieveFriends
{
GKLocalPlayer *lp = [GKLocalPlayer localPlayer];
if (lp.authenticated)
{
[lp loadFriendsWithCompletionHandler:^(NSArray *friends, NSError *error)
{
if (friends != nil)
{
[self loadPlayerData: friends];
}
}];
}
}
-(void) loadPlayerData: (NSArray *) identifiers
{
[GKPlayer loadPlayersForIdentifiers:identifiers withCompletionHandler:^(NSArray *players, NSError *error)
{
if (error != nil)
{
// Handle the error.
}
if (players != nil)
{
// Process the array of GKPlayer objects.
}
}];
}
Run Code Online (Sandbox Code Playgroud)
有关更多参考,您可以使用Apple Game KIT指南.下面是它的链接
希望能帮助到你..
| 归档时间: |
|
| 查看次数: |
4120 次 |
| 最近记录: |