I'm trying to create a subclass of SKShapeNode in swift as SKShapeNode(circleOfRadius: radius) but there is no designated init for it.
Anyone have any workarounds or info about why? I'm not sure if this is a bug or intentional. I found this video demonstrating a workaround for SKSpriteNode but its not working for me. https://skillsmatter.com/skillscasts/5695-how-to-subclass-a-skspritenode
Overall i am trying to make a subclass for an SKShapeNode that i can then subclass from again to have different versions of to easier manage my code. TIA
Thanks Martin i found that example earlier. It works but how would i make that into a circle instead of a rectangle?
import Foundation
import SpriteKit
class Player : SKShapeNode {
override init() {
super.init()
self.name = "Player"
self.fillColor = UIColor.blackColor()
}
init(rectOfSize: CGSize) {
super.init()
var rect = CGRect(origin: CGPointZero, size: rectOfSize)
self.path = CGPathCreateWithRect(rect, nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
In Main Code
let playerOne = Player(rectOfSize: CGSize(width: 100, height: 100))