Michael Geddes Michael Geddes - 1 year ago 100
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"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download