iosswiftbuttonsprite-kitsknode

Can I Attach a Label to a SKNode?


I am creating a game that needs to have a label be attached to a node because I am using it as a button and the button moves around. Does anyone know how to attach a label to a SpriteKit node?


Solution

  • There is SKLabel, you can use that

    let scoreLabel = SKLabelNode(fontNamed: "Chalkduster")
    scoreLabel.text = "Score: 0"
    scoreLabel.horizontalAlignmentMode = .right
    scoreLabel.position = CGPoint(x: 980, y: 700)
    addChild(scoreLabel)