Book Image

iOS 9 Game Development Essentials

By : Chuck Gaffney
Book Image

iOS 9 Game Development Essentials

By: Chuck Gaffney

Overview of this book

Table of Contents (15 chapters)
iOS 9 Game Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

SceneKit basics and working with nodes


Like SpriteKit, SceneKit is based on the concept of nodes. SpriteKit objects are children of the SKNode class, while SceneKit objects are children of the SCNNode class.

The preceding image is the SceneGraph hierarchy from Apple's SceneKit introduction. As we see, SceneKit has various nodes that branch off from the SCNScene class. These include the generic SCNNode for lights, geometry, and the camera.

Nodes are a tree data structure that can have other nodes added to them and have information of other nodes in the structure. As seen in the preceding graph, it's shown with the childNode[] array and parent properties. Spatial information, such as position, scale, and orientation, can be received from these properties. This is what makes nodes unique to other parent-child structuring in object-oriented design (OOD).

In SpriteKit, we'd typically add a node to our scene or to another node within our scene via the addChild() function. In SceneKit, the same functionality...