Inside scenes, you can have a number of layers (kind of like in Photoshop), and layers can contain nodes such as sprites, labels, menus, or more. For example you might have a scene for the initial menu for the game, another for the main action of the game, and a game over scene to end. If all works OK, you should see the following:Ĭocos2D is organized into the concept of scenes, which are kind of like “levels” or “screens” for a game. Go ahead and build and run the template as-is. Start up XCode and create a new Cocos2D project by selecting the iOS\cocos2d v2.X\cocos2d iOS template, and name the project Cocos2DSimpleGame. Let’s start by getting a simple Hello World project up and running by using the Cocos2D template you just installed. Note: If you already have Cocos2D 1.X installed and are worried about installing Cocos2D 2.X because it might override your current Cocos2D 1.X templates, don’t panic! :] Cocos2D 2.X installs its templates in a separate folder, so you can have the templates for both versions of Cocos2D installed side by side. Congrats – you’re now ready to work with Cocos2D! You should see “Installing cocos2d templates” and a bunch of messages. Open up a Terminal window to the directory you downloaded Cocos2D to, and enter the following command: So in this tutorial, you will use the “unstable” version.įor this tutorial, download the latest unstable version of Cocos2D 2.X.Īfter you pull down the code, you’ll want to install the useful project templates. Don’t worry, even though it’s called “unstable” it’s actually pretty good usually :] I’ve noticed that generally it takes a long time for useful new features to move from “unstable” to “stable.” So I tend to go for the “unstable” versions so I have all the good new stuff. You’ll also notice there’s “stable” and “unstable” versions. Shaders are a fancy thing in OpenGL ES 2.X that allows you to create some cool effects that you just can’t do with OpenGL ES 1.X.Īlthough both versions of Cocos2D work fine and there are tons of great games made with both versions, in this tutorial you’ll use the latest and greatest, Cocos2D 2.X. This is changing though, as more and more people move to Cocos2D 2.X! So there’s a lot of code out there that only works with Cocos2D 1.X. Unless you have prior experience with OpenGL, this probably doesn’t mean much to you :]Īll you need to know for now is the following: The main difference between these two versions is that under the hood, Cocos2D 1.X is made with OpenGL ES 1.X, and Cocos2D 2.X is made with OpenGL ES 2.X. You’ll notice there are several different choices you have about which version to download: Cocos2D 1.X vs Cocos2D 2.x, and stable vs stable choices. You can download Cocos2D from the official Cocos2D-iPhone home page. (Jump to Part 2 or Part 3 of the series.) Downloading and Installing Cocos2D You can follow along with the series, or just jump straight to the sample project at the end of the article. This tutorial series will walk you through the process of creating a simple game for your iPhone with Cocos2D, from start to finish. I ended up making a simple game of my own, and thought I’d write a tutorial series based on my experience in case it might be useful to other newcomers. It has sprite support, cool graphical effects, animations, physics libraries, sound engines, and a lot more.īack when I first started learning Cocos2D, there were several useful tutorials on getting started with Cocos2D out there, but I couldn’t find anything quite like what I was looking for – making a very simple but functional game with animation, collisions, and audio without using too many advanced features. Here’s the pre Cocos2D 1.X version if you need it!Ĭocos2D is a powerful library for the iPhone that can save you a lot of time while building your iPhone game. This tutorial series is now fully up-to-date for Cocos2D 2.X, Xcode 4.5, and has a ton of improvements such as Retina display and iPhone 4″ screen support. Note from Ray: You guys voted for me to update this classic beginning Cocos2D tutorial series from Cocos2D 1.X to Cocos2D 2.X in the weekly tutorial vote, so your wish is my command! :]
0 Comments
Leave a Reply. |