AJ Bredell AJ Bredell - 3 years ago 115
iOS Question

SKLabelNode not appearing in proper position

I am running through an entry level xCode course and am working with SKLabelNode. I have quadruple checked my code to be duplicate of his yet my label is appearing 99% off the screen it appears? Please help.enter image description here

enter image description here

Answer Source

By Default Anchor point of your main scene is set to x= 0.5 and y=0.5, So, when you add a new node, it's coordinates starts from center of screen.

Now, either you can change the anchor points of your scene as

    self.anchorPoint = CGPoint(x: 0.0, y: 0.0)
    let label = SKLabelNode(text: "Player Score")
    label.fontColor = SKColor.white
    label.fontSize = 60
    label.position = CGPoint(x: self.frame.width/2, y: self.frame.height/2)


or you can change the position of label to :-

label.position = CGPoint(x: 0, y: 0)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download