我正在创建一个需要将标签附加到节点的游戏,因为我将其用作按钮并且按钮移动。有谁知道如何将标签附加到SpriteKit节点?
有SKLabel
,你可以使用它
let scoreLabel = SKLabelNode(fontNamed: "Chalkduster")
scoreLabel.text = "Score: 0"
scoreLabel.horizontalAlignmentMode = .right
scoreLabel.position = CGPoint(x: 980, y: 700)
addChild(scoreLabel)
您需要调查SpriteKit中的父节点和子节点。你的标签最终将成为一个SKLabel,一个孩子点击你的按钮。因此它将与其父级一起移动,缩放,旋转等。