Hello, there,
I'm having this strange problem. I have a SKLabelNode as parent, and a SKSpriteNode as child, SKLabelNode's zPosition = 100, SKSpriteNode's zPosition = 0, the expected result is we see the label text on top of the SKSpriteNode. But when I run the code, sometimes the label node shows and sometimes doesn't(apparently goes under the child node). Here's my didMoveToView code in SKScene
override func didMoveToView(view: SKView) {
let cloud = SKSpriteNode(imageNamed: "Cloud")
cloud.position = CGPoint(x:0, y: 0)
cloud.zPosition = 0
let label = SKLabelNode(text: "this is a test")
label.fontColor = UIColor.blackColor()
label.fontSize = 40
label.position = CGPoint(x: CGRectGetMidX(self.frame), y: CGFloat(CGRectGetMidY(self.frame)))
label.zPosition = 100
label.addChild(cloud)
self.addChild(label)
}
This feels like a bug to me, but still I could be making some stupid mistakes somewhere. the reason I have SKLabelNode as parent other than other way around is because I want the SKLabelNode and SKSpriteNode moving together and if I set SKSpriteNode as parent, text on the label will blink when moving.
any help would be much appreciated,
Ron