Sunday, May 1, 2011

Mac OS X/iOS Game programming with Cocos2d - Part 1 Basic Setup

In this new regular series of tutorials i will show you how to create games for Mac OS X and iOS.
I will cover Xcode, Objective-C and the cocos2d framework. I will not cover everything down to the basics so you should have some understanding of programming in general.







What you need

Stable
Mac OS X Snow Leopard
Xcode 4.0
cocos2d 1.0

Bleeding Edge
Mac OS X Lion (dp)
Xcode 4.1 (dp)
checkout latest cocos2d sources via git

git clone git://github.com/cocos2d/cocos2d-iphone.git
cd cocos2d-iphone
git checkout develop

System Setup

Install Xcode 4
Install cocos2d Xcode 4 templates

cd Downloads
tar -zxvf cocos2d-iphone-1.0.0-rc.tar.gz
cd cocos2d-iphone-1.0.0-rc
sudo sh install-templates.sh

Project Setup

Start Xcode and start a new Project.


As template choose "chipmunk" from the cocos2d category.
Chipmunk is one of the 2 built in physic engines in cocos2d. I choose this instead of "box2d" cause it's faster and not written in (obj)c++.
You can also create a simple cocos2d project without any physics engine.

Next you must choose a name for the game, we go with "TestGame" in this tutorial. When asked where to save the project i recommend you make a new directory dedicated to this tutorials. Make sure to select "create local git repository for this project" it will allow you to use snapshots and versioning. We will cover git later in more detail.


You will now see your project in the Xcode workspace.
You can start your game by pressing the play button in the upper left corner.
This will start the application in the iPhone simulator (default iOS on iPhone4)


Gratulation, we a have a working iOS game. In the next part we will look at some of the Objective-C concepts and start to implement a real game.

35 comments:

neversettleforsecond said...

this is so cool! thx man :)

Flodström said...

Does this work for pc too? I think I've read that these tools are not available

mac-and-me said...

@Flodström
sorry, xcode is only available for os x

Kingmush said...

My girlfriend is getting into this business, will show her this! Great post!

Emrecan S said...

Look's pretty cool!

Zach said...

Awesome tutorial, I love doing stuff like this in my free time.

TheJackKelly98 said...

that sounds awsome, haven't messed around with xcode for a while

GADAFINY said...

cool thanks

phthalo. said...

Though I can't follow the instructions (not having regular enough access to a Mac), I will be following the series. Always helps to learn something new like this.

Jeremy said...

Hm.. I don't usually use a Mac, but I'm always about learning new computer related things. Even though I've never truly been a fan of Macs, however.

Colin Biano said...

this would be cool if i had a mac ;_;

=dgrphx= said...

so much git

Rachel Neilson said...

Thank you for this!

ed said...

i have no understanding of programming but this is cool of you to do

Jay said...

my mind.

Jay Reid said...

Good stuff!

JFoster said...

Have you made anything using these tools?

Trelin said...

wish I didn't have to have a mac to program for iOS.

Janez said...

@trelin exactly xD

Anyways a nice guide

Frosty said...

i always sorta wanted to learn to code, but not everything that goes with it

King Elysium said...

cant wait for more tuts!

Patti D. said...

That is insane, make your own games?

Matt said...

I am really looking forward to seeing more of your tutorials soon!

CandleintheDark said...

This is an awesome tool!

goat-on-a-stik said...

I hear it's very profitable to make apps for the store... hmm...

Glovey said...

I'm liking this! keep up the good work!

Danny Murphy said...

Useful stuff mate, cheers

princy gupta said...

so much coolll

Mike said...

This all sounds way too confusing for me, I hope it helps someone though!

ds said...

Good info. I think I'll make a game like Mad Birds or something. :p

Blogs4Hogs said...

This is way too technical for me, but I'm glad others are getting a lot out of this post!

Kim Anders said...

cool app!

-_vinyl_- said...

nice app!

Vague Raconteur said...

When I finally get a MacBook Pro, I'm making some apps ASAP.

Curtis said...

Thanks for the thorough game programming explanation. Mobile applications and games are a huge trend for developers right now and are equally popular in the marketplace. Your simple but complete instructions for the iOS and Mac OSX are very helpful.