【问题标题】:Issue with Game Center on MonotouchMonotouch 上的 Game Center 问题
【发布时间】:2013-07-28 05:34:26
【问题描述】:

我正在尝试在我的游戏中实现 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 示例,但在我的游戏中看不到任何身份验证窗口。我可以看到“欢迎回来,姓名”通知,但在我从游戏中心应用程序注销并重新打开我的游戏后,但我看不到任何身份验证窗口。

我该如何解决?

提前致谢

【问题讨论】:

    标签: xamarin.ios game-center


    【解决方案1】:

    只需拨打FinishedLaunching

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

    这应该会显示一个游戏中心“toast”,上面写着“欢迎回来,玩家 1”。

    如果这不起作用,这里有一些想法:

    • 确保您已在开发者门户中设置了新的捆绑包 ID,并在您的 Info.plist 中声明它
    • 开始在 iTunes connect 中填写您的应用详细信息(至少是描述、关键字、图标、1 个屏幕截图),并确保启用 Game Center 并将您的新游戏添加到组中
    • 在 Game Center 中使用测试 iTunes 用户登录(在 ITC 中创建),或与您的开发者帐户关联的登录名

    PS - 我不担心检查 iOS 4.1,现在只针对 iOS 5.0 及更高版本。

    【讨论】:

    • 感谢您的回复。我已经在我的应用程序代码中执行此操作。但我有一个不同的问题。有时我可以看到“欢迎回来,玩家 1”吐司,但我看不到登录当我从 Game Center 应用程序注销时的窗口。示例应用程序没有问题。可能正在显示登录视图,但它位于我自己的 uiview 控制器下方。游戏中心的身份验证窗口如何知道它将使用哪个 uiview 来显示此登录视图?
    • 您是否看到我上面示例中控制台上打印的任何内容?控制台中还有其他错误吗?
    • 控制台中没有错误。这个用于身份验证的 uialertview 可能位于我的 iphoneosgameview 之下。这是我的基本应用程序类:github.com/libgdx/libgdx/blob/master/backends/… 我必须在那里添加?
    • 这必须是一个私有的 Github 仓库,我得到一个 404。你的应用程序崩溃了吗?还是游戏中心登录没有出现?它是一个模式视图控制器,将以纵向显示。
    • 链接见我的第一篇文章:IOSApplication.java。我的应用没有崩溃。游戏中心登录视图没有出现。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-22
    • 2015-12-11
    相关资源
    最近更新 更多