Back to the Hero
You can now add code to add the hero to your game. The following code uses a block or a sphere, but you can use whatever you would like:
func addBlock() { var blockGeo = SCNBox(width: 1, height: 1, length: 1, chamferRadius: 0) block = SCNNode() block.geometry = blockGeo block.geometry?.firstMaterial?.diffuse.contents = UIColor.redColor() block.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.Dynamic, shape: SCNPhysicsShape(geometry: blockGeo, options: nil)) blockCam = SCNNode() blockCam.position = SCNVector3Make(0,14,10); blockCam.rotation = SCNVector4Make(Float(1.0), Float(0.0), Float(0.0), Float(-M_PI_4*0.75)); blockCamRot = blockCam.rotation blockCam.camera ...
Get Learning Swift™ Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.