«

»

Create an iPhone Game Using the Cocos2d Framework

Mobile devices are changing the way we work and interact with each other. A new wave of revolution is upon us in which people will consume more data through the mobile device than through any other device. The iPhone app store epitomizes the success and the popularity of mobile apps—and games are its hottest category. In this article I will demonstrate how to get started with creating iPhone games using the Cocos2d framework.

What Is Cocos2d Framework?
Cocos2d is an open source framework that is used to build iPhone games. It is built on top of the core iPhone SDK and exposes easy-to-use APIs to accelerate the development of iPhone games.

Downloading and Installing Cocos2d Framework and Templates
The first step to unleash the power of the Cocos2d framework is to download and install the framework and the templates associated with the framework. You can download the framework and templates here.

Understanding the Basics
Before we begin creating our first iPhone game, it’s a good idea to review the basics of the Cocos2d framework, which includes the following elements:

Scenes. Scene is a special node that is the parent of all the nodes. The purpose of scenes is to represent a playable part of the game and also to represent screens (e.g., game over, title page, high score list).

Layer. Layer represents an actual area where the game is played. Layers in Cocos2d serve a similar purpose as they do in Photoshop. This means a single scene can be composed of multiple layers. One layer can represent the background, and the other layer is where the game action takes place.

Sprites. Sprites represent the objects that give character to the game. For example, if you’re building a space game, your spaceship and aliens can serve as sprites. Each character that is involved in amplifying the user game experience can be considered a sprite.

Creating Your First Cocos2d Project
Open Xcode and create a new project. From the project template menu select Cocos2d Project, as shown in Figure 1.

136107_Cocos2d template for Xcode 01_0
Figure 1: Cocos2d template for Xcode

Click Choose to proceed to the next screen. Enter MyFirstCocos2dProject as the name of the project, then click Save. This will create the Cocos2d project with the default template. This article uses version 0.99 of Cocos2d framework, which by default searches for SDK version 4.0. If you have the latest SDK installed, then you will get the Base SDK Missing message shown in Figure 2.

136107_Cocos2d project template base SDK missing 02_0
Figure 2: Cocos2d project template base SDK missing

All you need to do is to tell Cocos2d framework that we are using a newer version of the SDK. To do this, go to Edit Project Settings under the Project tab and then specify the SDK version, as shown in Figure 3.

136107_Selecting installed SDK for iOS device 03_0
Figure 3: Selecting the installed SDK for iOS device

As, you can see in the above screenshot, the iOS SDK 4.0 is missing, but we can select iOS SDK 4.1. After selecting the correct SDK, build the project using Command B. There should be no errors in the project. At that point, you can press Command R to run the application. Figure 4 shows the application running and the iPhone simulator in action.

136107_Default Cocos2d project template output 04_0
Figure 4: The default Cocos2d project template output

Article source: http://www.devproconnections.com/article/mobile-development/create-iphone-game-cocos2d-framework-136107

Incoming search terms:

  • Published News Upcoming News Submit a New Story Groups toys r us application
  • Powered by Article Dashboard toys r us application
  • Powered by Article Dashboard toys r us coupon code
  • Published News Upcoming News Submit a New Story Groups example of a source code
  • Powered by Article Dashboard coupon codes
  • Powered by Article Dashboard action figure
  • Published News Upcoming News Submit a New Story Groups general code
  • Powered by Article Dashboard doctor who- the adventure game online
  • Published News Upcoming News Submit a New Story Groups example of
  • Powered by Article Dashboard parry sound women

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>