Book Image

Swift Game Development - Third Edition

By : Siddharth Shekar, Stephen Haney
Book Image

Swift Game Development - Third Edition

By: Siddharth Shekar, Stephen Haney

Overview of this book

Swift is the perfect choice for game development. Developers are intrigued by Swift and want to make use of new features to develop their best games yet. Packed with best practices and easy-to-use examples, this book leads you step by step through the development of your first Swift game. The book starts by introducing Swift's best features – including its new ones for game development. Using SpriteKit, you will learn how to animate sprites and textures. Along the way, you will master physics, animations, and collision effects and how to build the UI aspects of a game. You will then work on creating a 3D game using the SceneKit framework. Further, we will look at how to add monetization and integrate Game Center. With iOS 12, we see the introduction of ARKit 2.0. This new version allows us to integrate shared experiences such as multiplayer augmented reality and persistent AR that is tied to a specific location so that the same information can be replicated on all connected devices. In the next section, we will dive into creating Augmented Reality games using SpriteKit and SceneKit. Then, finally, we will see how to create a Multipeer AR project to connect two devices, and send and receive data back and forth between those devices in real time. By the end of this book, you will be able to create your own iOS games using Swift and publish them on the iOS App Store.
Table of Contents (22 chapters)
Swift Game Development Third Edition
Contributors
Preface
Other Books You May Enjoy
Index

Chapter 1. Designing Games with Swift

Apple's newest version of its flagship programming language, Swift 4.2, is the perfect choice for game developers. As it matures, Swift is realizing its potential to be something special, a revolutionary tool for app creators. Swift is the gateway for developers to create the next big game in the Apple ecosystem. We have only started to explore the wonderful potential of mobile gaming, and Swift is the modernization we need for our toolset. Swift is fast, safe, current, and attractive to developers coming from other languages. Whether you are new to the Apple world, or a seasoned veteran of Objective-C, I think you will enjoy making games with Swift.

Apple's website states the following:

"Swift is a successor to the C and Objective-C languages."

My goal in this book is to guide you step by step through the creation of a 2D and a 3D game for iPhones and iPads. We will start with installing the necessary software, working through each layer of game development, ultimately publishing our new game to the App Store.

We will also have some fun along the way! For the 2D game, we aim to create an endless flyer game featuring a magnificent flying penguin named Pierre. What is an endless flyer? Picture hit games such as iCopter, Flappy Bird, Whale Trail, Jetpack Joyride, and many more—the list is quite long.

Endless flyer games are popular on the App Store, and the genre necessitates that we cover many reusable components of 2D game design. I will show you how to modify our mechanics to create many different game styles.

For the 3D game, we will be using SceneKit. Like SpriteKit, which is used to develop 2D games, SceneKit is a framework developed by Apple to make 3D games. The 3D game we will be an obstacle avoidance game, in which there will be obstacles players will have to either go under or jump over.

In later chapters, we will see how to make augmented reality games using Apple's newest framework, ARKit. With ARKit, you can make really stunning augmented reality games. We will see see how to develop AR games using SpriteKit and SceneKit. Along with developing a 2D AR game, we will also see how to bring the SceneKit game we developed for 3D to life using the ARKit. In addition, we will also see how to create a Multipeer Augemented Reality App using ARKit and Multipeer Connectivity framework.

My hope is that our demo project will serve as a template for your own creative tasks. Before you know it, you will be publishing your own game ideas using the techniques we explore together.

In this chapter, we will cover the following topics:

  • Why you will love Swift

  • What you will learn in this book

  • New in Swift 4.2

  • Setting up your development environment

  • Creating your first Swift game

  • Exploring the SpriteKit demo