添加游戏中心排行榜

时间:2017-01-17 07:46:35

标签: swift viewcontroller game-center skscene game-center-leaderboard

我是Swift的新手,在将我的Sprite Kit游戏添加到游戏中心排行榜时遇到了麻烦。我为排行榜创建了一个按钮,但它在SKScene中,似乎Game Center的代码需要在View Controller中?我已将代码添加到我的单个View Controller中,但现在我不知道该去哪里。再一次,我对此非常陌生并完全失败 - 任何帮助都将非常感激。

1 个答案:

答案 0 :(得分:0)

您可以使用UIViewController子类创建一个cocoa触摸类。在viewdidLoad中你可以使用这样的东西:

if let view = self.view as! SKView? {
        // Load the SKScene from 'GameScene.sks'
        if let scene = SKScene(fileNamed: "Level1") {
            // Configure the scene
            [...]

            // Present the scene
            view.presentScene(scene)
        }

不要忘记导入GameKit。

相关问题