Game Development Reference
In-Depth Information
// Optional, but nice to be turned on during
developement
sceneView. showsStatistics = true
sceneView.allowsCameraControl = true
}
func createMainScene() -> SCNScene {
var mainScene = SCNScene(named: "art.scnassets/
hero.dae")
return mainScene!
}
}
Next you will create a floor for the spaceman to walk on. In the GameViewControl-
ler class, you will create a new method that will create the floor node.
In the function declaration, you can see you will return an SCNNode to the caller. This al-
lows you to easily refactor the code if you choose to at a later date.
func createFloorNode() -> SCNNode {
}
Next you create two variables, one that will be used as the return SCNNode and an
SCNFloor to create the geometry for the SCNNode .
let floorNode = SCNNode()
let floor = SCNFloor()
The SCNFloor is a special Scene Kit class that creates an infinite plane. It is important
to know that this plane will extend along the x- and z-coordinates, with the y-coordinate is
set to zero.
floorNode.geometry = floor
floorNode.geometry?.firstMaterial?.diffuse.contents
= "Floor"
return floorNode
In this section of code, you will set up the geometry for the floorNode . A node can
have only one geometry assigned to it, so to create animated geometries, you would create
an empty node and add child nodes to it. For the floorNode , you won't be creating an-
imated geometries, but that's something I will touch on later in creating the game.
Search WWH ::




Custom Search