Michael Geddes Michael Geddes - 1 year ago 61
iOS Question

SKLabelNode not showing up

I am trying to get an SKLabelNode to show up on my screen, but it doesn't show. Here is my code...

override func didMoveToView(view: SKView) {

let textLabel = SKLabelNode(fontNamed: "Avenir-Black")

textLabel.text? = "HI THERE"
//textLabel.position = CGPoint(x: frame.midX, y: frame.midY)
textLabel.horizontalAlignmentMode = .Center
textLabel.verticalAlignmentMode = .Center
textLabel.fontSize = 100
textLabel.zPosition = 2
textLabel.color = UIColor.whiteColor()
textLabel.name = textLabel.name

self.addChild(textLabel) }

What am I doing wrong?

Answer Source

The code should be written as

textLabel.text = "Hi there"

and not

textLabel.text? = "Hi there"