Let us now see how we can access each of the objects in the scene graph and add gravity to the monster. Later in this chapter, we will see how we can add a touch interface by which we will be able to make the hero character jump by applying an upward force.
So, create a new function called addColladaObjects
and call an addHero
function in it. Create a global variable called heroNode
of type SCNNode
. We will use this node to access the hero object in the scene. In the addHero
function, add the following code:
init(currentview view:SCNView){
super.init()
scnView = view
_size = scnView.bounds.size
//retrieve the SCNView
//scene = SCNScene()
scene = SCNScene(named: "monster.scnassets/monsterScene.DAE")
scnView.scene = scene
scnView.allowsCameraControl = true
scnView.showsStatistics = true
scnView.backgroundColor = UIColor.yellowColor()
self.addColladaObjects...