Ios 我可以将标签附加到节点上吗?
我正在创建一个需要在节点上附加标签的游戏,因为我将其用作按钮,按钮会四处移动。有人知道如何将标签附加到SpriteKit节点吗?有Ios 我可以将标签附加到节点上吗?,ios,swift,button,sprite-kit,sknode,Ios,Swift,Button,Sprite Kit,Sknode,我正在创建一个需要在节点上附加标签的游戏,因为我将其用作按钮,按钮会四处移动。有人知道如何将标签附加到SpriteKit节点吗?有SKLabel,您可以使用它 let scoreLabel = SKLabelNode(fontNamed: "Chalkduster") scoreLabel.text = "Score: 0" scoreLabel.horizontalAlignmentMode = .right scoreLabel.position = CGPoint(x: 980, y: 7
SKLabel
,您可以使用它
let scoreLabel = SKLabelNode(fontNamed: "Chalkduster")
scoreLabel.text = "Score: 0"
scoreLabel.horizontalAlignmentMode = .right
scoreLabel.position = CGPoint(x: 980, y: 700)
addChild(scoreLabel)
您需要调查SpriteKit中的父节点和子节点。您的标签将最终成为一个SKLabel和您按钮的子节点。因此,它将与其父对象一起移动、缩放、旋转等