Game Development Reference
In-Depth Information
nested nodes. The nice thing about nesting related nodes is that when you change the par-
ent node, the same changes will be applied to all the child nodes.
To see how nested nodes are represented in the node tree, let's go back to the node tree
represented by Figure 2-4 . If you want to nest additional nodes inside node4 , you can do
so by executing the following snippet right after the previously executed
node2.removeFromParent() . Figure 2-5 represents the results of this snippet.
var node4a = SKSpriteNode()
var node4b = SKSpriteNode()
var node4c = SKSpriteNode()
node4.addChild(node4a)
node4.addChild(node4b)
node4.addChild(node4c)
Figure 2-5 . The gameScene's node tree with nodes nested inside node4
Rendering the Node Tree
Now that you know how to build the node tree, it is time to look at how the node tree is
rendered. The order in which you add nodes to your scene is important. When the scene is
rendered at the end of the rendering loop, it is rendered in reverse order of the way it was
built. Let's use the node tree represented by Figure 2-3 as an example. When this node
tree is rendered, the scene will render each node in the following order:
1. node3
2. node4
Search WWH ::




Custom Search