Swift 添加游戏中心排行榜
我是Swift新手,在我的雪碧套件游戏中添加游戏中心排行榜时遇到困难。我为排行榜创建了一个按钮,但它在一个场景中,似乎游戏中心的代码需要在一个视图控制器中?我已经将代码添加到我的单视图控制器中,但现在我不确定该去哪里。再一次,我对这一点非常陌生,完全不知所措——任何帮助都将不胜感激 您可以使用UIViewController子类创建cocoa touch类。在viewdidLoad中,您可以使用如下内容:Swift 添加游戏中心排行榜,swift,viewcontroller,game-center,skscene,game-center-leaderboard,Swift,Viewcontroller,Game Center,Skscene,Game Center Leaderboard,我是Swift新手,在我的雪碧套件游戏中添加游戏中心排行榜时遇到困难。我为排行榜创建了一个按钮,但它在一个场景中,似乎游戏中心的代码需要在一个视图控制器中?我已经将代码添加到我的单视图控制器中,但现在我不确定该去哪里。再一次,我对这一点非常陌生,完全不知所措——任何帮助都将不胜感激 您可以使用UIViewController子类创建cocoa touch类。在viewdidLoad中,您可以使用如下内容: if let view = self.view as! SKView? {
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。您可以使用UIViewController子类创建cocoa touch类。在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