
- 500 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
eBook - ePub
iOS Game Programming with Xcode and Cocos2d
About this book
This book is written by a professional instructor and founder of CartoonSmart.com, a company specializing in new media tutorials for nearly a decade. The book is a start-to-finish guide for anyone looking to begin iOS development using Cocos2d and Xcode and submit their finished app to Apple. Even if you haven't read code before, you can begin with this book. This book is a handy reference guide, with easy to look-up sections of code snippets, pictures and links to video examples.
Features:
- Code
- Video examples
- 5 hours of tutorial videos on Box2d, which can take the reader even further beyond what they learned in the book
Frequently asked questions
Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access iOS Game Programming with Xcode and Cocos2d by Justin Dike in PDF and/or ePUB format, as well as other popular books in Computer Science & Digital Media. We have over one million books available in our catalogue for you to explore.
Information
Chapter 1
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.

Section 1
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...
Table of contents
- Cover
- Half Title
- Title Page
- Copyright Page
- Bound to Create
- Dedication
- Table of Contents
- About the Author
- The Code
- Chapter 1: The Hardest Part: Starting
- Chapter 2: Objective-C Basics
- Chapter 3: Cocos2d Basics
- Chapter 4: Create Your Own Class
- Chapter 5: Collisions, Touches, and Gestures
- Chapter 6: Accelerometer and Actions
- Chapter 7: Animation and Particle FX
- Chapter 8: Menus, Sounds, Scenes, and Text
- Chapter 9: Game Structure
- Chapter 10: Extending Cocos2d
- Chapter 11: The Back
- Glossary-Index