Quite the twisted trail it’s been since we first noticed cocos2d-iphone way back in 2008 and watched it grow, split, recombine, be acquhired, and eventually have the founder jump ship for the C++ version cocos2d-x. It was looking bleak there for us peoples tasteful enough to revile the thought of sullying ourselves with other, lesser, platforms for a while there until Apportable stepped up to support what’s been a surprisingly frantic divergence from the cross-platform strains, not least the currently misnomed rechristening as “Cocos2D-Swift”.
And today, we’re going to take a look at the first and only so far book out there on learning modern Cocos2D-Swift,
The book follows the style of introducing concepts over the course of developing a single game called ‘CocoHunt’ which can be downloaded from the App Store and has its source available on Github. It assumes basic familiarity with Xcode and Objective-C, focusing solely on Cocos2D coding. And, unfortunately, that means no discussion of SpriteBuilder, which our first reaction is a significant flaw in an introductory book to modern Cocos2D. But let’s take a walkthrough of the book, as described by itself in the Preface:
Chapter 1, All About Cocos2D, provides basic information about game engines, additional information about Cocos2D, as well as examples of great games created with Cocos2D.
In which our above concern is addressed:
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.
Well, that’s a valid perspective. Ours is to put off learning anything that there’s easier ways to accomplish, since after 20+ years in this industry we figure that knowledge becomes obsolete so fast that investing more than the minimum you can get away with is generally a misallocation of resources.
Chapter 2, Hello Cocos2D, guides you through the installation process and reviews the contents of the Cocos2D distribution package and demo projects that come with it.
And runs you through a hello world project with a sprite and label. Straightforwardly done.
Chapter 3, Cocos2D – Under the Hood, describes the architecture of the framework and its main classes. In the second part of this chapter, we will review several Cocos2D configuration options.
This would have been a good chapter to use as an introduction to SpriteBuilder, relating the architecture to SpriteBuilder’s layout. As it is, it’s a bit awkwardly placed to break rhythm. As the author acknowledges:
I know that you want to start writing the code and creating games as soon as possible. If you just can’t fight this feeling, then skip to Chapter 4…
That we’d say is a solid clue that our suggestion is a good one. (OK, we swear we’ll stop harping on SpriteBuilder now. Really.)
Chapter 4, Rendering Sprites, begins to unveil the process of game creation. In this chapter, we will add a game scene, background image, player, and enemy characters. We will review some of the main properties of Cocos2D nodes and will make them move, rotate, flip, and so on.
Remarkably well done chapter! As well as all the display basics you’ll need, smoothly works in anchor points, character composition, and use of TexturePacker even.
Chapter 5, Starting the Action, covers the process of controlling the game using states, handling touches, or using a gyroscope to get player input. At the end of this chapter, we will have a skeleton of a playable game.
Another excellent chapter, thoroughly covers interactivity as described and works in some good coordinate spaces and vector math discussion too.
Chapter 6, Rendering Text, shows you how to display score, lives, earned points, and winning and losing labels. In this chapter, we will use both True Type and Bitmap font-based labels of Cocos2D and will discuss benefits and performance considerations.
Straightforward and competent; covers Glyph Designer too.
Chapter 7, Animations and Particle Systems, demonstrates the use of different animation types and shows how to use particle systems to get really cool effects such as explosion and fire.
Competent enough for a beginner book, although we would’ve liked a little more on skeletal animation; covers Particle Designer too.
Chapter 8, Adding Sound Effects and Music, shows how to easily add sound effects and music, switch between music tracks, and adjust audio properties.
Chapter 9, User Interface and Navigation, concentrates on creating a convenient user interface using Cocos2D controls such as buttons, the scroll view, table view, and so on. In this chapter, we will see how to create scenes that exist in most games, such as the menu scene, about scene, and so on, and how to navigate between them.
That sound like a lot to cover? Yes it is, and the “and so on” covers a good many asides. There’s a bit too much crammed in here we think, probably would have been a bit easier to follow if focused into UI and navigation chapters; but it’s certainly very good as is.
Chapter 10, Physics, shows how to use the physics engine in your game. In this chapter, we will create a playable level using the physics engine; we will review how to create physics objects, adjust their properties, detect and filter collisions, use joints, and so on.
Yet another exceptionally well done chapter. Can’t think of an introduction to using physics engines we’ve ever read that was better than this, actually; balances features and explanation just about perfectly to get you started.
Chapter 11, Working with Tile Maps, explains tile maps and shows the complete process of creating and using a tile map in the game.
Including parallax animation as well, which is a nice feature to have explained in a learning book.
Chapter 12, Standing Out – Integrating Game Center and In-App Purchases, covers integrating Game Center and adding In-App purchases to the game.
For some reason, you have to download this chapter separately and the Preface link doesn’t work. But once you get past that gratuitous annoyance, again a straightforward and competent explanation of the described tasks. And bonus points for a nice collection of various asset-finding links for the penniless indie to finish off the book with!
So overall, we’re pretty darn impressed here, quality ranges from nicely done to downright outstanding all the way through the book; the best introductory Cocos2D book written yet, we’d say. Our only serious problem with it is that there isn’t any introduction to SpriteBuilder. And there’s a book devoted to that in progress by Steffen Itterheim, so if you’re more of a visual tool type person you might want to wait for that one. But if you want to get started NOW!, or you’re not a visual type person, then hey this is your best and most current choice for learning Cocos2D-Swift!