Learn Cocos2d game programming.
All the way from the top.
So, this is your first iOS game. Actually, it may even be your first game altogether! Taking it all in from day one can be daunting: figuring out OpenGL calls, understanding Objective C iterators and making sense of Cocos2d nodes and scenes is just too much to swallow in one gulp. Trust us, we’ve been there. You’ve this great idea sketched on a piece of paper, but somehow translating it into code looks terribly difficult.
That’s where the first Game Kit module comes in. If you are the learn-by-doing kind of programmer, reading source code from a real, working game will make learning faster and more fun. The bundled 100+ page book will go over all the basics, and explain how everything comes together. Doxygen-generated documentation will make understanding the code a breeze, and the included art will provide everything you need to make your own game, even if you don’t see yourself drawing sprites. Plus you get handy pieces of code you can reuse and extend in your own creations, saving time, energy and hassle. This introductory starter kit teaches everything there’s to know about iPhone game creation using Cocos2d, even if this is the first game you've ever made. And if for some reason you don’t find it useful, we are offering a 60-day full refund on your money. So what are you waiting for to take it out for a spin?
Meet the star of the show
Cocos2D is the leading, open-source, royalty-free iOS game engine. It’s easy to use, community-supported, reliable, mature, and thousands of iPhone, iPod touch, iPad and even Mac OS X games have been published using it. And now, thanks to Cocos2D-X, it’s possible to release games for Android, Windows and Linux as well, all with the same API.
Why is Cocos2D so easy to use? Cocos2d breaks all of your game's code objects down into nodes. Nodes automatically keep track of their parent node and their children nodes: you can set up a scene object as the parent, then add a sprite object to the scene and forget all about it. As you move the scene, Cocos2d will automatically move the sprite. And thanks to a unified action-running methodology, all OpenGL calls and other animation details are handled by the engine, meaning you just need to write a few lines in Objective C to make the magic happen.
The iPhone Game Creation for Beginners module explores this functionality, and teaches you how to use it on your own games. We've included a sample project dedicated to just Cocos2D basics and an entire chapter of the book breaks in Cocos2D's main concepts. We even include a Cocos2D skeleton project that you can copy, paste, rename and start a new game like snapping your fingers.
Trust us, you'll fall in love with it
You’ve probably got some experience with computer languages. Everybody knows some HTML, right? But Objective C… what’s it like? Is it worth learning?
A lot of programmers say they like Objective C better than C++, even after years and years of programming games in C & C++. The way message parameters are explicitly named will keep your code elegantly readable and Xcode’s auto-completion is handier than a hammer in a field of half-driven nails.
Going over this module, you’ll also gain familiarity with the iOS Software Development Kit (SDK). It’s a few gigs of frameworks, application programming interfaces (APIs), developer tools, sample projects and documentation. It really, really helps to know where to begin!
We’ll learn how to navigate the SDK and get your game to fly with the Xcode Integrated Development Environment (IDE). You’ll understand Xcode and be running your games with complete confidence in no time.
That feeling you get when you see your first character come to life, it's electric! He's moving, he's dancing and now he's backflipping and making karate noises! Oh. The joys.
Characters in 2D games are made up of spritesheets: a large number of sprites put together in a single file. We show the user one sprite when the character is standing, one sprite when it’s attacking and another when it’s moving. To create the illusion of real movement, we actually use more than one sprite to do that: animations are just a sequence of sprites. If you’re making games, you’ll spend a lot of time using sprites!
This module teaches you how to animate your own characters with a spritesheet maker. You drag all the individual sprites into the spritesheet maker, set exactly how you'd like the file to be exported and then publish. Voila. A spritesheet. And we make it extra easy for you by including a handy class called KITProfile. Our KITProfile code works by loading all the spritesheets, sprites, animations, sound effects and custom attributes associated with your character from a property list (.plist) file.
Because you'll need to do a lot more than code
Designing games is much easier and far more entertaining than most people think. It really rocks! Most professional game designers have to write huge documents full of exact specifications and other mumbo-jumbo before the game ever gets a chance to see the light of day. Being an indie game programmer, you can skip over the mundane details and just sketch your heart out.
It really is that easy to design a game! Just sketch out whatever you'd like to happen in the game. If you really want to get detailed, draw some buttons and draw all the particular "scenes" you're game will use (like the game scene, the character inventory scene and the main menu scene).
Now that you've got a design it's time to strategize your time investment. You need to divide the your overall game into phases and then divide those phases into bite-sized chunks. This is where having the previous experience of writing a game comes in handy, so we've made sure to dedicate an entire chapter of the book to this subject. You'll have a clear picture of how you are going to invest your time.
Work all those *oinks*, *bangs* and *splashes* into your game.
You’ll need sound effects, ambience and music to make your game truly come to life. These days, acquiring sound effects and music is as easy as browsing the web, but incorporating them into your game can be tricky. We’ll teach you how to do that using CocosDenshion, and even make it easier by including our very own KITSound class, that handles the asynchronous loading of sound effects. When your code specifies to load a sound effect it doesn't have to wait for the sound to finish loading before it continues to do other stuff, like load artwork and get the game going. Net result? Your game appears to load faster and you have happier players.
Another cool thing about KITSound is that it has a method to play a sound effect at a distance from the camera. Normally, your camera is centered around your main character, so you can compute this distance by calculating the length of the vector from the main character to the place where the sound effect is occurring. Once you've got that distance, you just feed it into KITSound's playAtADistance method and it will appropriately set the volume and panning of the effect for you.