我正在用精灵套件制作游戏,在我使用之前一切都很好GameCenter
,这是我的代码
define the Gameviewcontroller:
var GameController:GameViewController = GameViewController()
当您触摸内部的节点时TouchecBegan
:
let touchLocation = (touches as NSSet).anyObject()?.locationInNode(self)
let targetNode = self.nodeAtPoint(touchLocation!)
if targetNode.name == "leader"{
print("hhhh")
GameController.showGamecenetr()
}
并在GameViewController
代码中ShowGameCenter
:
func showGamecenetr() {
print("jijijijji")
GameKitHelper.sharedInstance.showGKGameCenterViewController(self)
}
它应该弹出视图GameCenter
,但显示错误:
无法将类型的值UIView
转换为SubView
我发现这是一个非常容易的错误,但我以前从未在这里遇到过,我不知道如何处理它,有人可以帮助我吗?
这是里面的代码showGKGameCenterViewController()
func showGKGameCenterViewController(viewController:UIViewController!){
if !gamecenterEnable {
print("No user!")
return
}
let gameCenterViewController = GKGameCenterViewController()
gameCenterViewController.gameCenterDelegate = self
gameCenterViewController.viewState = .Leaderboards
viewController.presentViewController(gameCenterViewController, animated: true, completion: nil)
}
帮助帮助;(