我正在尝试使用Swift对SKShapeNode
进行子类化。到目前为止,我已经做出了以下的代码:
import UIKit
import SpriteKit
class STGridNode: SKShapeNode {
init() {
super.init()
self.name = "STGridNode"
self.fillColor = UIColor(red: 0.11, green: 0.82, blue: 0.69, alpha: 1)
}
}
在我的代码中,我想要做类似于以下的事情:
let s = STGridNode(rectOfSize: CGSize(width: 100, height: 100))
所以我的问题是 - 我如何在STGridNode
的初始化程序中实现rectOfSize
?我已经尝试过:init(rectOfSize: CGPoint) {
super.init(rectOfSize: rectOfSize);
}
但是这会出错:'Could not find an overload for init that accepts the supplied arguments'