我该怎么办?在SpriteKit swift中它说:Type' GameScene'不符合协议' GKGameCenterControllerDelegate'?

时间:2016-06-09 21:07:58

标签: ios iphone xcode swift game-center

我在SpriteKit swift编码,直到我收到此错误说," Type' GameScene'不符合协议' GKGameCenterControllerDelegate' &#34 ;.我该怎么办?该错误出现在类GameScene上。 (错误不是我没有结束括号,因为我的结束括号位于下方,我没有显示):

import SpriteKit
import GameKit
import UIKit
import GoogleMobileAds
struct PhysicsCategory {
static let Enemy :UInt32 = 0x1 << 0
static let SmallBall : UInt32 = 0x1 << 1
static let Mainball :UInt32 = 0x1 << 2
}

class GameScene: SKScene, SKPhysicsContactDelegate, GKGameCenterControllerDelegate,GADBannerViewDelegate {

    var Mainball = SKSpriteNode(imageNamed: "MainBall")
    var redmain = SKSpriteNode(imageNamed: "white")
    var greenmain = SKSpriteNode(imageNamed: "white")
    var darkred = SKSpriteNode(imageNamed: "white")
    var orange = SKSpriteNode(imageNamed: "white")
    var yellow = SKSpriteNode(imageNamed: "white")
    var lightblue = SKSpriteNode(imageNamed: "white")
    var blue = SKSpriteNode(imageNamed: "white")
    var purple = SKSpriteNode(imageNamed: "white")
    var pink = SKSpriteNode(imageNamed: "white")
    var origin = SKSpriteNode(imageNamed: "white")

2 个答案:

答案 0 :(得分:0)

你需要在某处实现这个方法

gameCenterViewControllerDidFinish(_:)

请参阅apple的文档here

答案 1 :(得分:0)

您声明GameScene符合GKGameCenterControllerDelegate,但您尚未实施所有必要的方法。

您需要在班级中实施gameCenterViewControllerDidFinish(_:)