Game Development Reference
In-Depth Information
Xcode project and drop them into Xcode's image asset catalog: Images.xcassets .
All of the images that you will be using for this game will be added at this time.
Building the Scene
A good place to start is in the GameViewController class. You will need to remove
the temporary code in the viewDidLoad() method where you were creating an empty
SCNScene .
override func viewDidLoad() {
super.viewDidLoad()
}
You now have an overridden method that will call the superclasses' viewDidLoad
method to allow UIKit to finish completing anything it needs to do when the view loads.
After this call, you will create a variable.
let mainScene = createMainScene()
You will use separate methods to create the nodes. This will allow you to understand what
is going on and make it easier to refactor later if you want. So, now there is an error you
need to fix: the unresolved identifier.
func createMainScene() -> SCNScene {
var mainScene = SCNScene(named: "art.scnassets/
hero.dae")
return mainScene!
}
This method is small but powerful; this is where Scene Kit's power starts to be shown. As
you can see, you are loading a Collada file ( .dae ) that a 3D artist has provided you. Once
you finish coding the scene, with just a few more lines of code you will have the space-
man in his glorious 3D-ness.
Now let's add the scene that is being created to your view. In the viewDidLoad()
method, after your created scene, add the following code:
let sceneView = self.view as SCNView
sceneView.scene = mainScene
Search WWH ::




Custom Search