Reputation:
Here's a code to my back button using 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)
Upvotes: 3
Views: 762
Reputation: 35412
Probably you did wrong something like zPosition
, position
or where you add your label ( in what method and in what parent). Check out this example to see your label:
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)
}
Upvotes: 1
Reputation: 97
Try setting label's alpha to 1, and Z position to any number:
backButton.alpha = 1
backButton.zPosition = 1
Hope this helps.
Upvotes: 0