-2

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?

AtulParmar
  • 4,358
  • 1
  • 24
  • 45

2 Answers2

0

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)
Karthikeyan Bose
  • 1,244
  • 3
  • 17
  • 26
0

You need to investigate parent and child nodes in SpriteKit. your label will end up being an SKLabel and a child nod of your button. Thus it will move, scale, rotate etc with its parent.

Steve Ives
  • 7,894
  • 3
  • 24
  • 55