Subclass from SKLabelNode

2D_Apple_Games
Chapter 9
Intermediate Physics
page 240
Xcode Version 12.5.

I got 2 compiler messages.
Incorrect labels for candidate (have: ‘(fontName:)’, expected: ‘(message:)’) for
convenience init (message: String){

No exact matches in call to initializer for
self.init(fontName: “AvenirNext-Regular”)

The code from book(page 240):
class MessageNode: SKLabelNode {

convenience init(message: String) {

self.init(fontNamed: “AvenirNext-Regular”)

text = message

fontSize = 256.0

fontColor = SKColor.gray

zPosition = 100

let front = SKLabelNode(fontNamed: “AvenirNext-Regular”)

front.text = message

front.fontSize = 256.0

front.fontColor = SKColor.white

front.position = CGPoint(x: -2, y: -2)

addChild(front)

Please help.
P.S. Please understand that I am no looking for code that avoid to subclass SKLabelNode. I would like to find a code to allow subclassing SKLabelNode.
Thank you

This topic was automatically closed after 166 days. New replies are no longer allowed.