I am trying to make a number appear in the middle of an SKShapeNode. However, for some reason when I add the SKLabelNode as a child of the shape node, it does not appear despite the fact that the SKShapeNode does appear. I added the same label as a child of the SKScene and it appeared just fine. Here is the code for the custom class:
class Dot: SKShapeNode {
var numLabel = SKLabelNode(fontNamed: "MarkerFelt-Wide")
func setNumber(i: Int) {
numLabel.text = String(i)
numLabel.fontColor = UIColor.whiteColor()
numLabel.fontSize = 200
numLabel.setScale(numLabel.frame.width / self.frame.width / 2)
numLabel.position = CGPointMake(self.frame.midX ,self.frame.midY)
self.addChild(numLabel)
}
}
I call dot.setNumber(1)
but nothing happens. Please let me know if you find the issue. Thanks!