Game Development Reference
In-Depth Information
After adding the line of code, run the game. Now you see a pyramid near the spaceman, as
shown in Figure 11-8 .
Figure 11-8 . Spaceman scene with pyramid node
You now have some basic knowledge of how to create a primitive Scene Kit geometric
object. Why don't you go back to the Obstacle.swift file and use this pattern to cre-
ate four or five different objects? See Listing 11-2 .
Listing 11-2 . Obstacles Class
class Obstacles {
class func PyramidNode() -> SCNNode {
let pyramid = SCNPyramid(width: 10.0, height: 20.0,
length: 10.0)
let pyramidNode = SCNNode(geometry: pyramid)
let position = SCNVector3Make(0, 0, -100)
pyramidNode.position = position
pyramidNode.geometry?.firstMaterial?.diffuse.contents
= UIColor.blueColor()
return pyramidNode
}
class func GlobeNode() -> SCNNode {
let globe = SCNSphere(radius: 15.0)
let globeNode = SCNNode(geometry: globe)
globeNode.position = SCNVector3Make(20, 40, -50)
globeNode.geometry?.firstMaterial?.diffuse.contents
= UIColor.redColor()
Search WWH ::




Custom Search