Game Development Reference
In-Depth Information
//Add the following line to the GameViewController
setupEnemy():
enemyNode!.physicsBody = SCNPhysicsBody(type: .Dynamic,
shape: nil)
//Add the following line to the GameViewController
setupFloor():
floorNode.physicsBody = SCNPhysicsBody(type: .Static,
shape: nil)
//Add the following line to the GameViewController
setupWalls():
wall.physicsBody = SCNPhysicsBody(type: .Static, shape: nil)
//Add the following line to the Obstacle PyramidNode():
pyramidNode.physicsBody = SCNPhysicsBody(type: .Static,
shape: nil)
//Add the following line to the Obstacle GlobeNode():
globeNode.physicsBody = SCNPhysicsBody(type: .Static,
shape: nil)
//Add the following line to the Obstacle BoxNode():
boxNode.physicsBody = SCNPhysicsBody(type: .Static, shape:
nil)
//Add the following line to the Obstacle TubeNode():
tubeNode.physicsBody = SCNPhysicsBody(type: .Static, shape:
nil)
//Add the following line to the Obstacle CylinderNode():
cylinderNode.physicsBody = SCNPhysicsBody(type: .Static,
shape: nil)
//Add the following line to the Obstacle TorusNode():
torusNode.physicsBody = SCNPhysicsBody(type: .Static,
shape: nil)
The next part of getting the collision detection working is to create the bit masks that will
be used to determine when and if an object actually touches another one. Collision detec-
tion is based on using a bit mask that creates a table in order to determine whether two ob-
jects should collide. For this you will create a new file called SharedCon-
stants.swift , and you will use this file to create the bit mask variables that will be
used for all of your objects. Listing 14-7 is the code that you will need to add to this
newly created file.
Search WWH ::




Custom Search