这是使用SpriteKit,Swift 3
的后退按钮的代码var backButton = SKLabelNode()
backButton.text = "Back"
backButton.name = "backbutton"
backButton.position = CGPoint(x: self.frame.minX + 40, y: self.frame.maxY - 40)
backButton.fontColor = SKColor.red
backButton.fontSize = 30
self.addChild(backButton)
答案 0 :(得分:1)
可能你做错了zPosition
,position
或你添加标签的地方(用什么方法和用什么方式)。看看这个例子,看看你的标签:
override func didMove(to view: SKView) {
var backButton = SKLabelNode(fontNamed: "Arial")
backButton.text = "Back"
backButton.fontSize = 30
backButton.name = "backbutton"
backButton.fontColor = SKColor.red
self.addChild(backButton) // self is GameScene (an SKScene)
backButton.zPosition = 1
backButton.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
}
答案 1 :(得分:0)
尝试将标签的alpha设置为1,将Z位置设置为任意数字:
backButton.alpha = 1
backButton.zPosition = 1
希望这有帮助。