Book Image

Mastering Cocos2d Game Development

By : Alex Ogorek
Book Image

Mastering Cocos2d Game Development

By: Alex Ogorek

Overview of this book

Table of Contents (15 chapters)
Mastering Cocos2d Game Development
About the Author
About the Reviewers


If you've ever wanted to know what goes on in a great game from start to finish, this book will guide you through that process. You will discover that your games are just a few steps away from becoming the best games possible.

You'll be guided through a project and see what makes a game stand out when hundreds, or even thousands, of similar games fail to make any lasting impact. You'll experience the simplicity of Cocos2d, Chipmunk, OALSimpleAudio, and much more. You'll be given code for some unique game mechanics that will make your game stand out from the masses. This book ensures that no matter what scale of game you're working on is—whether it is indie or for a large publisher—you'll get the skills you need to create a highly polished and enjoyable experience for your players.

What this book covers

Chapter 1, Refreshing Your Cocos2d Knowledge, describes some tools you can use when developing your Cocos2d game, how to create an Apple Developer account, and also the importance of setting flexible goals when designing your project.

Chapter 2, Failing Faster with Prototypes, talks about the need for fast iterations and getting things up and running quickly. This chapter sets up the initial outline, or wireframe, for the book's project and goes into detail about using some of the tools introduced in the first chapter.

Chapter 3, Focusing on Physics, introduces the Chipmunk physics engine and the power behind it with only a few lines of code. This chapter shows you how you can integrate touch controls, physics, and the accelerometer all within a single project with ease.

Chapter 4, Sound and Music, covers the addition of sound and music, which are integral to a gaming experience. This chapter explains how to best use OALSimpleAudio and the various ways you can use sound within your game.

Chapter 5, Creating Cool Content, shows the use of particle effects, Bézier curves, and parallax scrolling. This chapter has three mini projects as well as some additions to this book's main project.

Chapter 6, Tidying Up and Polishing, explains the important process of polishing your game. There are many topics in this chapter, ranging from button animations to graphical changes. It explains in depth what you can do to make your game progress from a concept to a finished product.

Chapter 7 , Reaching Our Destination, finalizes the book's project and prepares everything for launch, including the creation of the app on iTunes Connect, setting up the loading screen and app icon, and adding analytics. This chapter also covers how to actually submit the game to the App Store and what to do after you submit it.

Chapter 8, Exploring Swift, introduces the Swift programming language (and the use of Swift with Cocos2d) through the creation of a very simple game. This chapter also explains the basics of how Swift works and the main differences between Swift and Objective-C.

Chapter 9, Simple Swift App, covers the basics of creating a nongame app using Swift as the main language. Although this chapter is not available in the book, it is available for download at

What you need for this book

Before reading this book, you should be armed with an understanding of how Cocos2d and Objective-C work. There is a brief introduction to Cocos2d concepts early on, but it wraps up quickly.

Besides that, anything used within the book is accompanied by a proper explanation on how to get it—whether that means downloading and installing a tool, setting up an account on iTunes Connect, or using the assets provided with this book.

Who this book is for

This book is aimed at developers who have a good handle on Cocos2d and Objective-C and want to take their game development skills to the next level. Maybe you've made games in the past that didn't get many downloads, and you want to create a higher-quality game. This book will help you polish your game to achieve what it deserves.


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, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "If you do not see the .xcodepoj file extension, don't worry. It should be labelled as the Xcode project in the kind filter and have a blueprint icon next to it."

A block of code is set as follows:

@interface MainScene : CCNode
  CGSize winSize;

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: "In SpriteBuilder, go to File | Publish. This will show a progress bar, and if your project is brand new, it'll go quite fast."


Warnings or important notes appear in a box like this.


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

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 for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit 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


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, 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 and enter the name of the book in the search field. The required information will appear under the Errata section.


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.


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.