class ColorRectangle: SKShapeNode {
var width: CGFloat!
var height: CGFloat!
var rectColor: UIColor!
convenience init(rectOfSize: CGSize, colorOfRectangle rectColor: UIColor) {
super.init(rectOfSize: rectOfSize)
self.width = rectOfSize.width
self.height = rectOfSize.height
self.rectColor = rectColor
self.fillColor = rectColor
self.strokeColor = rectColor
}
}
无法正确启动初始化程序。 我该怎么办?
答案 0 :(得分:2)
尝试像这样更改初始化程序:
class ColorRectangle: SKShapeNode {
var width: CGFloat!
var height: CGFloat!
var rectColor: UIColor!
convenience init(rectOfSize: CGSize, colorOfRectangle rectColor: UIColor) {
self.init()
self.init(rectOfSize: rectOfSize)
self.rectColor = rectColor
self.fillColor = rectColor
self.strokeColor = rectColor
}
}