2012-06-02 91 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