Search code examples
iosswiftsprite-kitskshapenode

More nodes than I should


Everytime I add 1 SKShapeNode, my total number of nodes shown in the simulator increases by 2. Is this a normal behaviour or should I get rid of the extra nodes, and how ? I'm on xcode 6.1 and iOS 8.1

    import SpriteKit

class GameScene: SKScene {
    override func didMoveToView(view: SKView) {
        /* Setup your scene here */
        let circle = SKShapeNode(circleOfRadius: 50)
        circle.fillColor = UIColor.blackColor()
        circle.position = CGPoint(x: self.frame.size.width/2, y:self.frame.size.height/2)
        self.addChild(circle)
    }
}

Thanks,


Solution

  • You get one node for the circle and one node for the filling of the circle. Try removing circle.fillColor = UIColor.blackColor(). Now the number of nodes only increases by 1.