Book Image

Learning iOS 8 Game Development Using Swift

By : Siddharth Shekar
Book Image

Learning iOS 8 Game Development Using Swift

By: Siddharth Shekar

Overview of this book

<p>Game development has been simplified with Apple's new programming language—Swift. If you're looking to start learning iOS development then you'll get everything you need - from&nbsp;the absolute basics such as the Xcode interface and takes you all the way to Swift programming.</p> <p>You will take a walk through the creation of 2D and 3D games followed by an introduction to SpriteKit and SceneKit. The book also looks at how game objects are placed in 3D scenes, how to use the graphics pipeline, and how objects are displayed on mobile screens. You will also delve into essential game concepts such as collision detection, animation, particle systems, and scene transitions. Finally, you will learn how to publish and distribute games to the iTunes store.</p>
Table of Contents (18 chapters)
Learning iOS 8 Game Development Using Swift
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Adding wall and floor parallax


What is a game without a parallax effect? In SpriteKit, we added parallax using sprites, while in SceneKit, we will use planes to add it to the scene. Apart from adding parallax, we will also see how to add diffuse, normal, and specular maps to the plane. Also, we will learn what those terms even mean.

So, as usual, we create a new function in which we will add all these planes. Add four global SCNNodes as follows:

var parallaxWallNode1: SCNNode!
var parallaxWallNode2: SCNNode!
var parallaxFloorNode1: SCNNode!
var parallaxFloorNode2: SCNNode!

Also, add a function to the scene called addWallandFloorParallax as follows:

    func addWallandFloorParallax(){
        
       //Preparing Wall geometry        
        let wallGeometry = SCNPlane(width: 250, height: 120)
        wallGeometry.firstMaterial?.diffuse.contents = "monster.scnassets/wall.png"
        wallGeometry.firstMaterial?.diffuse.wrapS = SCNWrapMode.Repeat
        wallGeometry.firstMaterial?.diffuse.wrapT...