Możliwe jest inicjowanie SKNodes z pustym inicjatorem, np. let node = SKNode()
. Podklasy SKNode
jednak łamią tę funkcjonalność. Po instacji SKNode
, Xcode generuje ten błąd, gdy próbuje użyć pusty inicjator na podklasy:Podklasa SKNode generuje błąd: nie można wywołać inicjalizatora dla typu "X" bez argumentów.
Cannot invoke initializer for type "X" with no arguments
Zakładając SKNodeSubclass
jest podklasą SKNode
linia let node = SKNodeSubclass()
generuje ten błąd.
Is it possible to subclass from SKNode and also use an empty initializer like with SKNode?
class StatusScreen: SKNode {
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
init(gridWidth: CGFloat, deviceHeight: CGFloat) {
super.init()
// Do stuff
}
}