2013-07-27 78 views
0

我正在嘗試將Game Center應用到我的遊戲中,但我遇到了問題。單點觸摸遊戲中心問題

這裏是我的Main.cs代碼:

namespace iosgame 
{  
    public class Application 
    { 
     [Register ("AppDelegate")] 
     public partial class AppDelegate : IOSApplication { 

      MainViewController mainViewController; 

      public AppDelegate(): base(new Game(new StaticsDatabase(),new StoreDatabase(),new InappPurchase(),new Social(),new MissionsDatabase()), getConfig()) { 

      } 

      internal static IOSApplicationConfiguration getConfig() { 
       IOSApplicationConfiguration config = new IOSApplicationConfiguration(); 
       config.orientationLandscape = true; 
       config.orientationPortrait = false; 
       config.useAccelerometer = false; 
       config.useMonotouchOpenTK = true; 
       config.useObjectAL = true; 
       return config; 
      } 

      // 
      // This method is invoked when the application has loaded and is ready to run. In this 
      // method you should instantiate the window, load the UI into it and then make the window 
      // visible. 
      // 
      // You have 17 seconds to return from this method, or iOS will terminate your application. 
      // 
      public override bool FinishedLaunching (UIApplication app, NSDictionary options) 
      { 
       base.FinishedLaunching(app,options); 
       UIViewController controller = ((IOSApplication)Gdx.app).getUIViewController(); 
       mainViewController = new MainViewController(); 
       controller.View.Add(mainViewController.View); 



       return true; 
      } 

      private bool isGameCenterAPIAvailable() 
      { 
       return UIDevice.CurrentDevice.CheckSystemVersion (4, 1); 
      } 
     } 

     static void Main (string[] args) 
     { 
      UIApplication.Main (args, null, "AppDelegate"); 
     } 
    } 
} 

這裏是Main.cs的超:https://github.com/libgdx/libgdx/blob/master/backends/gdx-backend-iosmonotouch/src/com/badlogic/gdx/backends/ios/IOSApplication.java

我試圖用這個https://github.com/xamarin/monotouch-samples/blob/master/GameCenterSample/GameCenterSample/MainViewController.cs例子,但我不能看任何認證窗口在我的game.I可以看到「歡迎回來,名稱」的通知,但是我從gamecenter應用程序退出後重新打開我的遊戲,但我看不到任何身份驗證窗口。

我該如何解決?

在此先感謝

回答

2

FinishedLaunching只需撥打這個:

if (!GKLocalPlayer.LocalPlayer.Authenticated) { 
    GKLocalPlayer.LocalPlayer.Authenticate (error => { 
     if (error != null) 
      Console.WriteLine("Error: " + error.LocalizedDescription); 
    }); 
} 

這應該顯示一個遊戲中心 「土司」 說: 「歡迎回來,玩家1」。

這裏有一些想法,如果這不起作用:

  • 請確保您有建立在開發者門戶的新包ID,並在Info.plist
  • 開始申報其填寫您的應用詳情在iTunes中連接(最少爲描述,關鍵字,圖標,1個屏幕截圖),並確保啓用Game Center並將您的新遊戲添加到羣組中
  • 用Game Center中的測試iTunes用戶登錄(在ITC中創建)與您的開發者帳號相關的登錄信息

PS - 我不擔心檢查iOS 4.1,只是針對iOS 5.0及更高版本。

+0

感謝您的回覆。我已經在我的應用程序代碼中執行了此操作。但我遇到了另一個問題。我可以看到「歡迎回來,播放器1」有時敬酒,但我無法在登出時看到登錄窗口來自Game Center應用程序。我對示例應用程序沒有任何問題。 可能登錄視圖正在呈現,但它在我自己的uiview控制器下面。遊戲中心的auth窗口如何知道它將使用哪個uiview來顯示此登錄視圖? – droidmachine

+0

有什麼想法嗎? – droidmachine

+0

您是否看到上例中的控制檯上印有任何內容?控制檯中有任何其他錯誤? – jonathanpeppers