In the final challenge of Chapter 11, in which we are asked to change the fill color and see it blend with the Texture, I find that when I do this, the arrow’s texture does indeed blend with the Texture background. However, the SKSpriteNode that was created in the level’s SKS scene file, which was set in code to have a fillColor of clear also changes to the new fillColor. I tried creating a reference to the arrow child by giving it a name of ‘arrow’ and then changing it in interact(), however, the original SKSpriteNode also changes color.
- Am I doing this wrong?
- Why is it that I cannot create an HintNode object in GameViewController and add it as a child unless there is an SKSpriteNode in the SKS file for the level?
CODE:
In HintNode
override func touchesEnded(_ touches: Set, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
interact()
}func interact() { color = colors[Int.random(min: 0, max: 2)] let node = childNode(withName: "arrow") as! SKShapeNode node.fillColor = color }
Thanks!