iOS 9 Game Development Essentials
Table of Contents
iOS 9 Game Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. The Swift Programming Language
Hello World!
No more semicolons
Variables, constants, and primitive data types
Variables
Constants
More about constantsâŠ
Arrays, matrices, sets, and dictionaries
Arrays
2D arrays / matrices
Sets
Dictionaries
Mutable/immutable collections
Editing/accessing collection data
Iterating through collection types
Objective-C and Swift comparison
Objective-C
Swift
Characters and strings
String Interpolation
Mutating strings
String indices
Commenting in Swift
Boolean
Ints, UInts, floats, and doubles
Integers and unsigned integers
Floats and doubles
Objects in Swift
Type safety and type inference
Optionals
Unwrapping optionals
Optional binding and chaining
Control flow in Swift
If statements
For loops
Do-while loops
Switch statements
Functions and classes
Functions
Tuples
Classes
Summary
2. Structuring and Planning a Game Using iOS 9 Storyboards and Segues
Model-View-Controller
An iOS app's lifecycle
The main() function
The UIApplication class/object
The AppDelegate class
View controllers
View controller types
Storyboards and segues
Segues
Storyboards versus coding
Summary
3. SpriteKit and 2D Game Design
A brief history of iOS game development engines
The game loop
Tile game â SwiftSweeper
What is SwiftSweeper?
Creating our SpriteKit game
An overview of the SpriteKit structure and objects
Scene transitions and the choice of code, storyboards, and/or SKS files
An SKTransition example
A SKScene/storyboard example
SKScene transitions with SKS files
Assets, sprites, and icons
Sprite atlases and animating sprites
Creating our game logic
GameBoard
Putting it all together in GameScene.swift
DemoBots
Summary
4. SceneKit and 3D Game Design
SceneKit basics and working with nodes
SpriteKit / SceneKit interactivity
The issue with inheritance-based structuring and game design
Our first SceneKit scene â the Xcode template
SceneKit project flow and structure
SceneKit Debugging Options
Handling user input in SceneKit
SceneKit features introduced in iOS 9 / Xcode 7
Audio nodes and 3D sound
Ambience and music
SpriteKit scene transitions in SceneKit
Fox demo
Particle systems
Placing particles into our pioscene
SpriteKit
SceneKit
Introducing SceneKit and SpriteKit physics
Visually composed game scenescgs
Summary
5. GameplayKit
Entities and components
Using GKEntity and GKComponent objects in our games
State machines
Agents, goals, and behaviors
Pathfinding
MinMaxAI
Random sources
Rule systems
Summary
6. Exhibit the Metal in Your Game
The Apple Metal API and the graphics pipeline
CPU/GPU framework levels
Graphics pipeline overview
What are shaders?
Types of shaders
Why is Metal faster than OpenGL ES?
The basic Metal object/code structure
Summary
7. Publishing Our iOS Game
The ever changing process of app submission
Before submitting your app
Preparing our apps for iTunes Connect
Submitting your app in the testing/beta phase
Creating an iTunes Connect app record
Updating the build string
Archive and validate your app
Upload your app to iTunes Connect
Beta test your game with the TestFlight service
External tester invites
Analyzing crash reports and feedback from testers
Submitting your game for review
Updating your game
Summary
8. The Future of iOS Game Development
A greater focus on functional programming
The Apple Watch
Component-based structuring
The rise of VR
Summary
Index
iOS 9 Game Development Essentials
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2015
Production reference: 1261015
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-143-0
www.packtpub.com
Cover image by Chuck Gaffney
Author
Chuck Gaffney
Reviewers
Mohit Athwani
Rahul Borawar
Chady Kassouf
Joni Mikkola
Commissioning Editor
Julian Ursell
Acquisition Editors
Vinay Argekar
Sonali Vernekar
Content Development Editor
Parita Khedekar
Technical Editor
Edwin Moses
Copy Editor
Dipti Mankame
Project Coordinator
Judie Jose
Proofreader
Safis Editing
Indexer
Hemangini Bari
Graphics
Abhinash Sahu
Production Coordinator
Nitesh Thakur
Cover Work
Nitesh Thakur
Chuck Gaffney is a programmer, voice actor, and game developer. He owns a company, Chuck's Anime Shrine, and has worked for some studios in New York. Some of Chuck's recent projects include VR and Unity projects for major studios and business firms, in addition to iOS and Swift programming.
Mohit Athwani is a self-taught iOS developer and has been developing apps since the early days of iOS 3. He has worked with several clients all around the world, and has carried out intense research in the field of facial detection and recognition on iOS. His app, iRajanee, became the number one app on the Indian app store, and has fetched him tremendous success.
Mohit started his company Geeks (http://www.geeksincorporated.net) with a friend in 2010, and has since also involved himself in conducting training sessions on iOS for students and corporates. His website, http://indianios.guru/, hosts a lot of introductory videos and tutorials on developing for iOS with Swift.