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

Preface

Since the introduction of iOS 8 in 2014, game development for the iOS platform has gone through some major changes. The first of those changes was the introduction of the Swift programming language, a functional programming language made by Apple to be simple to code and modern in its capabilities, all while being fast enough to handle modern app and game development. iOS 8 also introduced the 3D game development framework, SceneKit. SceneKit allowed developers to quickly design 3D games and work with 3D assets in a similar fashion to iOS 7's SpriteKit. A year later, in the summer of 2015, iOS 9 was introduced, along with a new set of tools for both seasoned and brand new iOS game developers. The new framework, GameplayKit, lets developers handle the game rules, AI, game entities, and game states separately from the inheritance logic. In addition to GameplayKit, Apple showed off the Fox game example that displays how Xcode can now do much of the same visual editing functionalities seen in multiplatform game engines, such as Unity and Unreal Engine.

We will first become familiar with the Swift programming language and how it can be used in the scope of game development. The goal is to understand iOS game development from the ground up, learning the tougher code-centric methodology of making a game. In addition to taking a look at Apple's own example projects for the various iOS game frameworks, we will see some code examples from two games, the first game being a published Swift-developed 2D scrolling game named PikiPop and the other being a tile-based Minesweeper clone named SwiftSweeper. As we progress through the book, we will still keep code as the core of our method for game development, but will look into the visual tools introduced in iOS 9 that, in addition to GameplayKit and the component-based structuring, can allow us to create a game that is only limited by our imagination. We then dive into topic of the low-level APIs, such as OpenGL ES and Metal, for developers who wish to get down directly to the GPU.

In the end, we hope that you understand how iOS continues to be a power game development platform, whether you are a developer who comes from the traditional code-centric school of computer science, or you are a part of the growing visual-based/drag-and-drop design paradigm. Our goal is that when you are finished with this book, you will have a number of vastly different and detailed game ideas, which you then can immediately begin building with Swift and the iOS 9 platforms.

What this book covers

Chapter 1, The Swift Programming Language, provides an introduction and guidance to the Swift programming language.

Chapter 2, Structuring and Planning a Game Using Storyboards and Segues, helps readers know the basic flow of an iOS app by making use of storyboards and segues in order to either plan or preplan iOS games.

Chapter 3, SpriteKit and 2D Game Design, introduces and explains the use of the iOS 2D game development framework, SpriteKit.

Chapter 4, SceneKit and 3D Game Design, helps readers look into the iOS 3D development framework, SceneKit, and visual tools introduced in iOS that can be used for both SceneKit and SpriteKit.

Chapter 5, Gameplaykit, introduces the GameplayKit framework, a universal game logic and AI framework introduced in iOS 9.

Chapter 6, Exhibit the Metal in your Game, discusses about advanced topics, such as the GPU graphics pipeline and an introduction to Apple's low-level API, Metal, for getting the best performance out of your game.

Chapter 7, Publishing Our iOS Game, explains the steps needed to beta test and publish iOS games by making use of the testing and quality assurance service, TestFlight.

Chapter 8, The Future of iOS Game Development, discusses how programming, iOS, and game development as a whole might change or improve in the near future, and how it relates to the most recent iOS platforms and frameworks.

What you need for this book

Here's what you need for this book:

  • Xcode 7 or later

  • Mac OS X Yosemite or later

Who this book is for

This book is intended for game developers who wish to develop 2D and 3D games for iPhone and iPad. If you are a developer from another platform or a game engine such as Android or Unity, a current iOS developer wishing to learn more about Swift and the latest features of iOS 9, or even if you are new to game development, then this book is for you. Some prior programming knowledge is recommended, but not required.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, filenames, file extensions, pathnames, and user input, are shown as follows: "As we can see, the AppDelegate.swift and the ViewController.swift files were automatically created for us and right below that, we'd find the Main.Storyboard file."

A block of code is set as follows:

let score = player.score
var scoreCountNum = 0

do {
    HUD.scoreText = String(scoreCountNum)
    scoreCountNum = scoreCountNum * 2
} while scoreCountNum < score

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

// Collision bit masks
typedef NS_OPTIONS(NSUInteger, AAPLBitmask) {
    AAPLBitmaskCollision        = 1UL << 2,
    AAPLBitmaskCollectable      = 1UL << 3,
    AAPLBitmaskEnemy            = 1UL << 4,
    AAPLBitmaskSuperCollectable = 1UL << 5,
    AAPLBitmaskWater            = 1UL << 6
};

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: " Alternately, imagine that the player lost all of their lives and got a Game Over message."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/iOS9_GameDevelopmentEssentials_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.