Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Learning iPhone Game Development with Cocos2D 3.0
Learning iPhone Game Development with Cocos2D 3.0

Learning iPhone Game Development with Cocos2D 3.0: Harness the power of Cocos2D to create your own stunning and engaging games for iOS

eBook
zł39.99 zł141.99
Paperback
zł177.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Learning iPhone Game Development with Cocos2D 3.0

Chapter 1. All About Cocos2D

Before diving deep into the fun world of game development, we will spend some time (but only a little) understanding what Cocos2D is, how it can help you develop games, and why you should use it.

In this chapter, we're going to review the following points:

  • What a game engine is and why you should use it
  • Why you should choose Cocos2D as a game engine
  • A list of games created with Cocos2D

    Note

    There are several versions of Cocos2D. The original Cocos2D is written in Python and was first released in 2008. There is also a C++ version called cocos2d-x, HTML5 version called cocos2d-HTML5, and several other versions.

    In this book, we're going to review the currently most popular version of Cocos2D, that is, Cocos2D Swift (previously named Cocos2D-iPhone). However, for brevity, I will just call it Cocos2D.

    If in future you will want to learn some other version, it will be quite easy, because all versions share the same architecture, main concepts, and a majority of functions.

Game engines

Long before the mobile-games era or even PC-gaming era, each game was created for a specific hardware. This means that if you wanted to create a game, you had to spend some time learning low-level details of hardware specification and take into account all of its characteristics, constraints, and sometimes, issues.

Then, when the game was completed and you wanted to create a different game, there was very little you could reuse from the previous games you created. We're not even speaking about porting your existing game to another platform. In this case, you just had to rewrite it almost from scratch.

But hey! We're very lucky to live in a different time. A game developer's life is much easier these days. In our time, we have a lot of different game engines at our disposal; these make our lives much easier.

So what is a game engine?

A game engine is a software framework that adds a level of abstraction between hardware, video drivers, sound drivers, and your code. Typical game engines provide the following functionalities:

  • Rendering: This is the main function of the majority of game engines. This function helps you actually draw something on the screen without the need to write any low-level code. In addition, a game engine sets up a lot of features for you, such as initializing graphics and loading textures. For example, using a modern game engine, you can draw a player character on screen with 2-3 lines of code compared to 30-50 lines of code if you're using OpenGL ES 2.0 directly. In addition to static drawing, game engines provide the ability to animate, scale, rotate, and do many other useful things just by changing an object property.
  • User input: There might be a few great games I don't know about, where you don't have to do anything and don't control the game flow in any way. You just watch what happens on the screen and enjoy (if you know of such games, let me know!). All the recent popular games take some kind of user input (cutting the rope with a finger swipe, touching to activate jetpack, and so on). A game engine lets you get that user input in a convenient manner and respond to it in the game.
  • Sound: Games with sound are so much better! Adding the right sound effects and music can turn a mediocre game into a real gem. Again, game engines come to the rescue and let you play sound effects and background music with only a few lines of code.

Some game engines provide additional functionalities such as physics engine, collision detection, scripting, artificial intelligence, networking and multiplayer support, and localization support. However, many great games were created only using the three functionalities mentioned earlier.

So what is this all about?

First, it is nice to know that you're lucky to live in a time when you can take a game engine and concentrate on making great games instead of spending time on learning hardware specification. So, you have no excuses to not start creating games right now!

Second, Cocos2D is a game engine, so it is a good idea to get a basic understanding of a game engine, its purpose, and its main functions.

Third, many developers including myself love to reinvent the wheel. If you're just beginning game development and considering whether you should invest your time in learning a game engine and using it, or learning low-level features such as OpenGL and possibly creating your own game engine with blackjack, I strongly advise you to start with a game engine such as Cocos2D.

You will learn a lot of game development concepts, and more importantly, you will be able to actually make games. After releasing your first game, you will get invaluable experience, and later, if you decide to dive deeper into low-level details, you will find it much easier after working with a game engine.

Also, it is nice to know that Cocos2D is based on OpenGL ES 2.0 and won't constrain you in any way. You will be able to write low-level code where you think it is required, but still leave all the routine work to Cocos2D.

Why Cocos2D?

Now that we have discussed why game engines are good for you, let's have a look why you should use Cocos2D.

Cocos2D is easy

You can start creating your first game in no time. A few chapters later, you will see this yourself. Cocos2D has a very beginner-friendly learning curve, and although there is a lot you can learn about Cocos2D, you can actually start making games and learn as you go.

This is very important, as making games is not about learning advanced tools; it is about creating a fun and exciting experience for your players. You don't have to master Cocos2D to create your first game that might reach the top of the AppStore.

Cocos2D is free

Yes, Cocos2D is completely free for commercial use. You will never have to pay anything for it, and there are a bunch of extensions, utilities, tools, and frameworks that work with Cocos2D. Of course, there are other free game engines, but some of them just don't reach the required quality level, and some of them are free only until you start to earn some real money, and I'm sure you're planning to do that.

I know it is tempting to buy the new, shiny game engine, because you think that if it costs money, it is better. Well, it is not always true. It is hard to believe, but Cocos2D's quality can be compared to top-level commercial products, and you still get it for free! Even more, big companies are not only using Cocos2D, but also contributing to it!

Cocos2D is popular

Cocos2D has a huge and very responsive community. You will almost never be left alone, struggling to solve some complicated tasks. A task is either already solved and maybe even integrated in Cocos2D, or there is a third-party framework or class implementing the required functionality.

Cocos2D is open source

You can have any opinion about open source projects, but I can assure that you will be very glad to have access to full source code when things go wrong. When you just start learning Cocos2D, you will mostly make errors that are easy to spot and fix; we've all done them. However, later, when you start doing some advanced stuff, having access to the under-the-hood internals of game engine is just great!

Regarding the source code, it is well written, well-structured, and commented. You can learn a lot just from reading it. In fact, I would suggest every beginner game developer read it at some point.

Want more?

In addition to all the preceding goodies, you will get the following too:

  • Physics simulation with the Chipmunk physics engine
  • Visual tools for building interfaces and levels
  • Porting to Android with only a few steps
  • Lots of ready-to-use controls
  • A lot of other features

    Note

    Porting to Android has become possible due to efforts of the Apportable company (www.apportable.com), which is a sponsor of Cocos2D project.

    They are also providing a great free tool called SpriteBuilder, which definitely stands out from the rest. High chances that after some time this will be the only tool you need to develop games for Cocos2D. With SpriteBuilder, you can design your scenes using GUI editor, create animations, edit physics shapes, and many more.

    However, using SpriteBuilder doesn't eliminate the need to write the code and understand how Cocos2D works. This is why, I strongly believe that first you need to learn pure Cocos2D and after that it will be very easy to start using SpriteBuilder and make your life even easier.

    Both SpriteBuilder and porting to Android are not covered in this book.

Games created with Cocos2D

I'm sure you are wondering if there are any great games created with Cocos2D. The answer is that there are plenty! Let's have look at some of them right now.

Note

This is only the tip of the iceberg. We physically cannot list all the great games made using Cocos2D, as it will take up a significant part of the book.

BADLAND

BADLAND is a very atmospheric side-scroller action game with great gameplay and graphics. BADLAND received a lot of awards (including an award from Apple) and reached the number one place in more than 80 countries.

The game makes good use of physics and has an amazing design. BADLAND was developed by a two-man game studio called Frogmind. A screenshot of the game is as follows:

BADLAND

Feed Me Oil 2

Feed Me Oil 2 is a great mind-bending puzzle game, where you need to deliver oil to the target zone using many different devices. The game reached the top of the AppStore and was featured in many countries. Its predecessor, Feed Me Oil, was also a great success!

The game was developed by an independent game developer, Alexander Ilin. A screenshot of the game is as follows:

Feed Me Oil 2

Lep's World 2

Lep's World 2 is a really cool and fun platformer game with more than 60 million downloads. The game reached the number one place in several countries and still is very popular. I think you won't be surprised to know that it was created using Cocos2D. A screenshot of the game is as follows:

Lep's World 2

Other games

The listed games here are just a small set of all the games created using Cocos2D. The games listed earlier were picked because of their quality, high ratings, and to be honest, because I like them. There are thousands of games created with Cocos2D.

If you don't believe me and want to see a huge list of Cocos2D games, please visit http://www.cocos2d-iphone.org/games. However, note that this is also not a full list of games, as it contains only the manually submitted games.

Summary

In this chapter, we've learned some general information about game engines and Cocos2D in particular. Don't worry if this part seems too abstract; it serves several very important purposes.

First, you should understand what benefits you get from using game engines, that is, a higher level of abstraction and faster development at the cost of less control. Don't worry; this cost is minimal with Cocos2D and in fact, is close to zero as Cocos2D is an open source project.

Also, if you were still deciding whether Cocos2D is the right way to go, this chapter should have dispelled all doubts. You've seen some examples of great and successful games developed using Cocos2D. I believe they will inspire you to create your own great and successful game.

In the next chapter, we're going to use a more practical approach. We will download and install Cocos2D and will create and run our first Cocos2D project.

Left arrow icon Right arrow icon

Description

This book is an easy-to-follow, step-by-step beginner's guide covering the full process of creating a game. It is packed with examples and illustrations, with comprehensive coverage of each topic. If you want to learn how to make games using the Cocos2D framework, this book is for you. If you would like to build a good foundation for a career in game development as an independent game developer or at a game studio, or if you just want to make games as a hobby, then you'll love this book. You should have some basic programming experience with Objective-C and Xcode. To run the code in this book, you will also need an Intel-based Macintosh running OS X Mountain Lion (or later).

What you will learn

  • Install Cocos2D and create projects using Cocos2D Xcode templates
  • Understand the Cocos2D architecture and its main classes
  • Render images and text, move and animate them
  • Control your game using touches and a gyroscope
  • Create a user interface and navigate between game screens
  • Use the physics engine to apply forces and detect collisions
  • Add sounds and music and change playback properties
  • Integrate your game with Game Center and make InApp purchases

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 25, 2014
Length: 434 pages
Edition : 1st
Language : English
ISBN-13 : 9781782160144
Vendor :
Apple
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jun 25, 2014
Length: 434 pages
Edition : 1st
Language : English
ISBN-13 : 9781782160144
Vendor :
Apple
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 597.97
Learning Cocos2d-x Game Development
zł197.99
Learning iPhone Game Development with Cocos2D 3.0
zł177.99
Cocos2d Game Development Blueprints
zł221.99
Total 597.97 Stars icon
Banner background image

Table of Contents

13 Chapters
1. All About Cocos2D Chevron down icon Chevron up icon
2. Hello Cocos2D Chevron down icon Chevron up icon
3. Cocos2D – Under the Hood Chevron down icon Chevron up icon
4. Rendering Sprites Chevron down icon Chevron up icon
5. Starting the Action Chevron down icon Chevron up icon
6. Rendering Text Chevron down icon Chevron up icon
7. Animations and Particle Systems Chevron down icon Chevron up icon
8. Adding Sound Effects and Music Chevron down icon Chevron up icon
9. User Interface and Navigation Chevron down icon Chevron up icon
10. Physics Chevron down icon Chevron up icon
11. Working with Tile Maps Chevron down icon Chevron up icon
A. Pop Quiz Answers Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7
(9 Ratings)
5 star 66.7%
4 star 33.3%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Amazon Customer Aug 19, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you’re new to iOS game development now is a great time to get started. In 2008 a brilliant engineer named Ricardo Quesada rewrote his 2D game engine for Apple’s iOS and released it as open source. It’s no exaggeration to say that hundreds of games, like my own, were developed using Cocos2D—including dozens of hits. Now it’s 2014 and the newbie game developer has several versions of Quesada’s Cocos2D framework to choose from. But for me the branch of Cocos2D devoted to the iPhone and iPad will always have a special place in my heart. Clearly Cocos2D-iPhone (now called Cocos2D-Swift) was the inspiration for Apple’s SpriteKit framework. And once you learn the fundamentals of Cocos2D on iOS you can easily transfer these skills to Android, Windows, and HTML5 versions of the Cocos2d family. Working with Cocos2d-Swift is like “reading Shakespeare in the original Klingon.”Learning iPhone Game Development with Cocos2d 3.0 by Kirill Muzykov is a book I wish I had when I was learning to develop my first iPhone game. Muzykov patiently covers all the basics (nodes, sprites, actions, text, sound, buttons, menus) and jumps into advanced topics (particles, physics, tile maps, iTunesConnect, Game Center, and in-app purchases) while guiding the reader though creating a game called CocosHunt and using important tools (Particle Designer, Texture Packer, Tiled) and websites (freesound.org, media.io).Along the way the reader also learns about Objective-C, Xcode, and iOS APIs. You’re still a beginner by the time you finish Muzykov’s book but you’re a well informed beginner and ready to tackle larger and more complex projects—like the next Candy Crush.One of the best things I like about Muzykov’s book is it’s structure. A typical chapter starts with setting up a project and cycles through segments entitled “time for action” and “what just happened?”. This alternating rhythm becomes a reliable way to digest the material and ensure the author doesn’t wave his hands over new concepts. Almost every chapter includes a pop-quiz. I’m not a big fan of quizzes but if that’s what you need to re-enforce the material Muzykov provides them.The source code is clean and clearly written with good comments. Muzykov keeps the syntax simple, using “typedef enum” instead of “typedef NS_ENUM” and “#define” instead of “FOUNDATION_EXPORT NSString *const” which is probably for portability. Much of a game is managing state and game developer who follow Muzykov examples in his classes won’t get into trouble.If you’re new to mobile game development and you want to focus on iOS then Learning iPhone Game Development with Cocos2d 3.0 is a good book for you.
Amazon Verified review Amazon
Amazon Customer Jul 31, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I started learning Cocos2d last year, and struggled because the books and tutorials I was coming across were outdated. This book takes care of that, covering Cocos2d v3 which is the latest version right now. I found the teaching on caching sounds, developing levels for retina/non-retina displays and UI layout most interesting. Additionally you'll learn how to use tools such as TexturePacker to handle assets in the game. This is a big deal, as a lot of time can be wasted as you are learning if you don't have a good book like this one on hand! My only regret with this book is that it was not around when I first started last year, as it would have saved me a ton of time!
Amazon Verified review Amazon
R.B. Aug 06, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
When a book normally starts with "its for everyone with no experience in game development and basic Objective-C skills"i get sceptic. But "Learning iPhone Game Development with Cocos2d 3.0" from Kirill Muzykov is a really rare exception of that.I was fascinated by the way the book explains all the details from sprites over physics to Tile Maps in an easy way. Addedwith great illustrations and simple, effective code. And all this on a game called "Hunter" which is a refreshing differenceto examples used in other books i read, because of it's "real world" character.The book is also full of hints (like debugging and understand FPS), side informations (like types of animation)and quiz like questions to test the reader 's knowledge about each chapter.I really wished this book was available when i start learning Cocos2D 3 years ago.From my side a clear 5 star review (the first time i give this for a book).
Amazon Verified review Amazon
tuomojau Jul 17, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
At the moment this book is one of the best books written of Cocos2d (and the most up-to-date with covering the v 3.0) It’s organized around the development of one single game through the whole book, which makes it clear and easy to follow. It gives a good view of everything that can be done with Cocos2d. I imagine that for beginners this is a must book, but also if one has some experience with Cocos2d this book has a lot of tricks and tips how to improve the code.
Amazon Verified review Amazon
Branislav Siarsky Feb 22, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Well written, logical, covering all must know aspects. After reading I was able to at least put my sprites in the desired order :)
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.