Game Development Reference
In-Depth Information
var playerNode1 = SKSpriteNode(imageNamed: "Player")
playerNode1.position = CGPoint(x: size.width / 2.0, y: 80.0)
addChild(playerNode1)
var playerNode2 = SKSpriteNode(imageNamed: "Player")
playerNode2.position = CGPoint(x: size.width / 2.0, y:
100.0)
addChild(playerNode2)
var playerNode3 = SKSpriteNode(imageNamed: "Player")
playerNode3.position = CGPoint(x: size.width / 2.0, y:
120.0)
addChild(playerNode3)
In this snippet, three player nodes are being added to the scene, each of them 20 points be-
low the most recently added node. To see the results, run the project again. You will see
the overlapping players, with the first player added on top, as shown in Figure 2-6 .
Figure 2-6 . The gameScene's with overlapping player nodes
Searching the Node Tree
Search WWH ::




Custom Search