这段代码在第一个XCode 6测试版上工作正常,但在最新的测试版上不起作用并显示以下错误必须调用超类SKSpriteNode的指定初始化程序
:
这段代码在第一个XCode 6 Beta版本中可以运行,但是在最新的Beta版本中无法运行并报出以下错误Must call a designated initializer of the superclass SKSpriteNode
:
import SpriteKit
class Creature: SKSpriteNode {
var isAlive:Bool = false {
didSet {
self.hidden = !isAlive
}
}
var livingNeighbours:Int = 0
init() {
// throws: must call a designated initializer of the superclass SKSpriteNode
super.init(imageNamed:"bubble")
self.hidden = true
}
init(texture: SKTexture!) {
// throws: must call a designated initializer of the superclass SKSpriteNode
super.init(texture: texture)
}
init(texture: SKTexture!, color: UIColor!, size: CGSize) {
super.init(texture: texture, color: color, size: size)
}
}
这就是这个类的初始化方法:
let creature = Creature()
creature.anchorPoint = CGPoint(x: 0, y: 0)
creature.position = CGPoint(x: Int(posX), y: Int(posY))
self.addChild(creature)
我被卡住了..最简单的解决方法是什么?