Book Image

iOS Game Programming Cookbook

Book Image

iOS Game Programming Cookbook

Overview of this book

Table of Contents (19 chapters)
iOS Game Programming Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Since the iOS devices are breathing in the market, the games have been started ruling this segment as well. iOS devices provide us with a really powerful gaming platform, which enables all the game developers to develop amazing games for this segment.

This book provides you with simple, direct solutions to all your common problems faced during game programming in iOS devices. This book covers a wide range of topics with detail and practical explanations. This book serves starts with simple game animations and an introduction to SpriteKit and then will grow the horizon towards working with the physics engine, 3D game programming, Artificial Intelligence for games and finally we will end up learning multiplayer game programming.

The book contains more than 45 interesting game recipes, which you need to learn and implement in your next game. This book serves as an all-in-one package for beginners, intermediates, and experts. You have complete control of each step of the game development. We also provide the solution kit at the end of each chapter once the recipe is finished.

What this book covers

Chapter 1, iOS Game Development, gets you started with the game development techniques with an understanding of the default game template and developing a mini game.

Chapter 2, SpriteKit, explains the basic structure of SpriteKit with the anatomy of game projects. Then later in the chapter we will take a deeper look into scenes, sprites and nodes. By end of the chapter we will be able to build a mini game with infinite scrolling.

Chapter 3, Animations and Texture, helps us to explore the depth of animations, which can be accomplished in iOS games. We will learn to create a texture atlas and create animations on them. We will also explore character animations and parallax backgrounds in this chapter.

Chapter 4, Particle System and Game Performance, makes us learn and understand the anatomy of particle effects and emitter system in games. In addition to that we will be exploring the evaluation of game performance in this chapter.

Chapter 5, Adding Music to iOS Games and an Introduction to iCloud, teaches us the numerous ways to add the music in the games. We will explore the various events to add music to the games such as background music and various other sounds effects on specific events. At end of the chapter, we will learn about iCloud integration in our games.

Chapter 6, Physics Simulation, gets us started on working with the physics engine in games in order to add more reality to the games. In this chapter, we will learn some exciting real-world simulations by creating a small game.

Chapter 7, Adding Reality to Games, broadens your scope in physics simulation by explaining the nitty gritty of physics joints, contact detection, and collision. In this chapter, we will explore the depth of physics and its impact on the overall game development process.

Chapter 8, Introduction to Game Math and Physics, brushes up your basic mathematics skills in the initial half of the chapter and then going forward explains their usage in the games. This chapter explains various aspects and properties of math and physics that are used in games.

Chapter 9, Autonomous Moving Agents, reveals the most interesting part of the games that is, artificial intelligence. In this chapter, we will practically implement various artificial intelligent behaviors in our game. We will explore, seek, flee, wander, arrive, pursuit, evade behaviors. Other than this, we will also learn group behaviors such as alignment cohesion and separation.

Chapter 10, 3D Game Programming with OpenGL, helps you in exploring 3D game programming. In this chapter we will learn the basics of OpenGL and then going forward in the chapter we will learn create a working 3D game model.

Chapter 11, Getting Started with Multiplayer Games, starts from the basics of the multiplayer game including the anatomy of multiplayer games. You will learn to set up a connection between two iOS devices and then will also learn to send and receive data from one device to another.

Chapter 12, Implementing Multiplayer Games, creates a multiplayer game using which two players can play simultaneously. In this chapter, we will use all the methodologies that we have learned in the introduction chapter.

What you need for this book

You'll need the following setup to get started with iOS game programming using SpriteKit:

  • An Intel-based Macintosh running Snow Leopard (OS X 10.6.8 or later)

  • Xcode

  • You must be enrolled as an iPhone developer in order to test the example projects on your device

  • iOS device with 7.0 or later

Who this book is for

If you are willing to learn game programming to develop your own games, then this book is for you. In this book, you will learn about various verticals of game development. This book will teach you a step-by-step way to write your own game.

This book uses Objective-C as its main language, so some basic knowledge of Objective-C is a must. This book assumes that you understand the fundamentals of object-oriented programming and programming in general.

This book is designed to get you started using game programming instantly, so you should be familiar with the iPhone/iPad itself. The iPhone is a great platform for programming. It looks nice and feels nice. This book teaches you about various easy-to-use approaches to get started with game programming.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

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

Code words in text are shown as follows: "In AppDelegate.h file, find the application:didFinishLaunchingWithOptions: method and where we are registering for push notifications."

A block is set of code will be shown as follows:

SKAction *sequence = [SKAction sequence:@[[SKAction rotateByAngle:degreeToRadian(-3.0f) duration:0.2],[SKAction rotateByAngle:0.0 duration:0.1],[SKAction rotateByAngle:degreeToRadian(3.0f) duration:0.2]]];
[touchedNode runAction:[SKAction repeatActionForever:sequence]];

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: "Select a location on the drive to save the project and click on Create."

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: https://www.packtpub.com/sites/default/files/downloads/8255OS_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.