I can't get the a sub class of SKShapeNode to accept an initialiser. To work around this I've tried to go by the example posted here Adding Convenience Initializers in Swift Subclass. The code i'm using is below.
class Ground1 : SKShapeNode {
override init() {
super.init()
print("Hello1")
}
convenience init(width: CGFloat, point: CGPoint) {
var points = [CGPoint(x: -900, y: -300),
CGPoint(x: -600, y: -100),
CGPoint(x: -100, y: -300),
CGPoint(x: 2, y: 150),
CGPoint(x: 100, y: -300),
CGPoint(x: 600, y: -100),
CGPoint(x: 900, y: -300)]
self.init(splinePoints: &points, count: points.count)
lineWidth = 5
strokeColor = UIColor.orange
physicsBody = SKPhysicsBody(edgeChainFrom: path!)
physicsBody?.restitution = 0.75
physicsBody?.isDynamic = false
print("Hello2")
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
When initialised the convenience init() is ignored and not used. Resulting in no shape being added to the scene. What am I doing wrong ?