2012-06-02 58 views
5

我想使用GameKit通过WiFi连接两台设备。 Apple的文档说如何在使用Gamekit时通过WiFi进行连接?

如果选择了Internet连接,则应用程序必须关闭对等选择器对话框并显示其自己的用户界面以完成连接。

这是我做的

- (void)peerPickerController:(GKPeerPickerController *)picker didSelectConnectionType:(GKPeerPickerConnectionType)type 
{ 
if (type == GKPeerPickerConnectionTypeOnline) 
{ 
    picker.delegate = nil; 
    [picker dismiss]; 
    [picker autorelease]; 

    [alert setTitle:@"\n\n\n"]; 
    [alert setMessage:@"Looking for other iPads, iPhones or iPod touches..."]; 
    [alert addButtonWithTitle:@"Cancel"]; 

    UIActivityIndicatorView *progress = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)]; 
    progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; 
    [alert addSubview:progress]; 
    [progress startAnimating]; 
    [alert show]; 
} 
} 

行,我也提出了我自己的接口。接下来呢?我如何连接?如何开始寻找同龄人?

回答

2

这个tutorial建立使用Gamekit和蓝牙或WiFi的对等纸牌游戏。 (链接更新)

+1

的联系是错误的 - 它关系到本教程一个广告。实际教程是在这里:http://www.raywenderlich.com/12735/how-to-make-a-simple-playing-card-game-with-multiplayer-and-bluetooth-part-1 – Adam