The Hardest Part: Starting
Right now there is a suitcase next to my bed that hasn't been unpacked from a vacation weeks ago. I am a procrastinator. Fortunately, I'm also a perfectionist. Once a job has started, it must be done right. It's just that starting part that trips me up. Whether it's cleaning mountains of clothes off the floor, reading unread emails, or writing an entire book.
Here's my challenge to you: overcome what is keeping you from not building that clever app festering in the back of your mind. Embrace whatever will tip the scales from doing nothing to doing something. It might be as simple as convincing yourself, “The time is right”.
Swear this oath … by turning to the next page, I promise to actually begin the project I've been dreaming of. It may bring fortune, fame, or even failure, but I will undertake a new adventure.
Why Program with Cocos2d?
Hopefully many of you reading this book are “on the fence” about whether or not to use Cocos2d for your next app. I say hopefully, because I want to convert you. I'd love to hear back from readers that tell me this book was the reason they got started using Cocos2d, or programming in general. I think Cocos2d is a very easy language to learn because it was made specifically for building 2D games and interactive applications. Think about that for a second, it was created with game developers in mind. If your main reason for reading this book is to create a game for the App Store, then this is a good language for you. I say, language but Cocos2d is better described as a framework. It uses Objective-C. So while you are learning Cocos2d in this book, you are also learning the Objective-C language. There will be times when it makes more sense to teach you something outside of the Cocos2d framework and work solely with the native code Apple provides for the iOS.
Some of you might be wondering if this is an iOS 7 book? At the time I'm writing this, iOS 7 has been released and the version of Xcode I'll be using to test my projects can build an iOS 7 app, but what we'll be doing in this book is largely independent of Apple's OS cycle. More important to us, is what version Cocos2d is at. Right now, Cocos2d is at version 2.x. I'll throw a little “x” in there because there's always some updates to the framework to account for things like iOS 7 being released. To train along with this book, your best bet is to use the latest version of Cocos2d, although most of my examples have been tested with Cocos2d version 1.x and run the same. Why is that?
The basics tend to stay the same for a long time. I think that's an important point to remember for anyone new coming to programming, because it's easy to fret over how much there is to learn when there's so much new code being introduced every year. If you worry about the latest code for the camera, Facebook integration, Passbook, etc., while you're still learning the basics, it's overwhelming. To encourage you, just remember that what you learn now rarely gets undone. New code to play with new things doesn't usually affect the old code to build the essentials. It's just new code, there when you want it. Also, because we are using Cocos2d in this book and focusing mostly on games, we are in a “walled garden” in a sense. The games we create don't even need to tap into the fancier features of the iOS (but they could if you wanted). My goal for you in this book is to keep things simple and focused on making games.
Who Am I? … A Programmer, Maybe?
I'm probably a lot like you. Even if you've never programmed anything before, I'll bet we're still more similar than dissimilar when it comes to programming. My background is in art and for all my past years working with code, I still don't think I'm all that smart. Somehow a decade and a half of fumbling around with code has flown by. It still doesn't seem that long ago that I was living in a closet-sized apartment in Manhattan spending my mornings in life drawing classes and evenings in a computer lab learning animation. The fact is though, I've probably spent ten thousand hours more as a professional programmer than I ever did as a professional animator. Still, for some reason, I feel like a fish out of water at times. That same feeling can drag you down throughout the learning process. Like, if you don't understand something now, you weren't meant to ever understand it. Disregard those thoughts. Will it take a decade to feel like you belong in front of a page full of code? Maybe. Maybe not. It doesn't matter, because feeling unsure of yourself doesn't have to stop you from making your first app or landing your first paid freelance gig as a programmer. There is a beginning to learning how to code, but there won't be an end. Every project can require knowing a little more than before. Maybe that's why countless other professional programmers like myself will always feel like they haven't mastered anything. We are all just students. Some of us double as teachers as well.
My main profession for almost a decade has been teaching video tutorials. That's longer than YouTube has been around. Weird, right? When my company CartoonSmart.com began I mostly taught Flash developers how to draw and animate. The illustration in the header of this section dates back to those past glory days of teaching simple things like how to draw. Eventually I started recording tutorials for Flash's programming language, which at the time was Actionscript 2. I taught some simple games, similar to Battleship, Missile Command, even a crude Mario Bros clone. Then Actionscript 3 came along and the language got less simple. I had to learn some better coding habits, like object-oriented programming. Just when I felt comfortable again, I tried an entirely new programming language because I got my first iPhone. It was a difficult switch at first, but a worthwhile adventure for sure.
There is something almost magical about publishing your work to an iOS device. Yes, I'll confess I've drunk the Kool-Aid of the Apple cult, but long before they ever made phones. My dad bought the first Mac computer. It's exciting to see a project you've coded get run on your Mac, but for some reason it is completely different to see what you've made on an iPhone or iPad. Maybe it's because running an app on your computer feels confined to only your...