O'Reilly logo

Learning iOS 8 Game Development Using Swift by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding objects and physics to the scene

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.

Accessing the hero object and adding a physics body

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required