简体   繁体   中英

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,

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.

If you don't do anything else (out of the ordinary) then just assume this is normal. Sprite Kit adds more nodes internally, for instance a SKLabelNode also has subnodes (for the label or individual letters) that you don't have any control over.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM