I have the following class that is a subclass of SKLabelNode. This class will not work without the
override init(){
super.init()
}
call. It seems that SKLabelNode is trying to call an init() method with no parameters, or something else is going on somewhere that is causing this issue.
Here is the simplified class.
import UIKit
import SpriteKit
class PulsatingText: SKLabelNode {
override init(){
super.init()
}
init (fontNamed:String!, theText: String!, theFontSize: CGFloat!){
super.init(fontNamed: fontNamed)
self.text = theText
self.fontSize = theFontSize
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
If i remove the
override init(){
super.init()
}
I get a runtime crash with the following error logged to the console.
fatal error: use of unimplemented initializer 'init()' for class 'MobileTutsInvaderz.PulsatingText'
Here is how I am calling the method.
let invaderText = PulsatingText(fontNamed: "ChalkDuster", theText: "INVADERZ", theFontSize:50)
I am also including a image of the stack trace below.

SKLabelNodeisinit(fontNamed fontName: String!), did you try to override it? - Nikita Ivaniushchenko