Game Development Reference
In-Depth Information
for i in 1...6 {
let material = SCNMaterial()
material.diffuse.contents = UIImage(named: boxImage +
String(i))
materials.append(material)
}
boxNode.geometry?.materials = materials
For the other obstacle types, add a color similar to how you did the PyramidNode . List-
ing 12-5 is the rest of the obstacles, so feel free to use different colors and images if you
happen to have some images available.
Listing 12-5 . Remaining Obstacle Materials
class func TubeNode() -> SCNNode {
let tube = SCNTube(innerRadius: 10, outerRadius: 14,
height: 20)
let tubeNode = SCNNode(geometry: tube)
tubeNode.position = SCNVector3Make(-10, 0, -75)
tubeNode.geometry?.firstMaterial?.diffuse.contents
= UIColor.redColor()
return tubeNode
}
class func CylinderNode() -> SCNNode {
let cylinderNode = SCNNode(geometry:SCNCylinder(radius:
3, height: 12))
cylinderNode.position = SCNVector3Make(14, 0, -25)
cylinderNode.geometry?.firstMaterial?.diffuse.contents
= UIColor.yellowColor()
cylinderNode.geometry?.firstMaterial?.specular.contents
= UIColor.yellowColor()
cylinderNode.geometry?.firstMaterial?.shininess = 0.5
return cylinderNode
}
class func TorusNode() -> SCNNode {
let torus = SCNTorus(ringRadius: 12, pipeRadius: 5)
let torusNode = SCNNode(geometry: torus)
torusNode.position = SCNVector3Make(50, 10, -50)
Search WWH ::




Custom Search