Cocos2d-X Meta-Project Setup

来源:互联网 发布:淘宝网 返利哪个好 编辑:程序博客网 时间:2024/05/17 09:32

原文:http://paralaxer.com/cocos2d-x-project-setup/

In this chapter we'll discuss how to create your own Cocos2d-X project files from scratch for iOS, Mac, Android and Windows.

If you'd like, you can download the project files to our complete example game, Paralaxer.

What will you need to follow along?

The iOS and Mac sections assert that you have a Mac computer and have already installed a stable release ofXcode with the iOS SDK. Xcode is a free development environment by Apple and much preferred by many a developer.

The Windows section asserts that you have a genuine copy of Windows XP, Vista, 7 or 8 withVisual Studio Express installed (also a free development environment). You can accomplish this setup on a regular PC or a Mac computer withBoot Camp.

The Android section asserts that you have already installed the Android SDK, NDK and Eclipse (which you now get along with the SDK). You can be ready to build for Android on Windows, Mac or Linux.

Note that the NDK we recommend installing is Google's Android NDK. We used to recommend the NDK from CrystaX, but lately there have been some issues with fopen.

Keep in mind that Xcode, Visual Studio, Eclipse and even Cocos2d-X are updated often. There are new options, build settings and sometimes UI elements have been rearranged. If you run into any significant snags, just be a go-getter, solve your riddle and let us all know the new answer in the comments.

According to a recent survey we took, iOS is the most popular deployment target for Cocos2d-X developers, with Android coming in a close second. So that's where we'll start.

iOS Project From Scratch

There are two ways you can create a Cocos2d-X iOS project from scratch:

  1. Install the Cocos2d-X templates, then do a New Project.
  2. Make a copy of samples/HelloCpp, then open the project and rename.

We'll take a look at both methods.

New iOS Project via Templates

Cocos2d-X comes packaged with a script which installs Xcode project template files for iOS. Just open Terminal, change to your cocos2d-x directory and run the command to install the templates:

cd Desktop/Paralaxer/Code/cocos2d-x/sudo ./install-templates-xcode.sh -f

Use sudo if you'd like the templates to be installed for all users.

Use the -f flag to automatically remove any existing Cocos2d-X template files and replace them with the newest.

Now that you've got the Xcode iOS templates installed, just open Xcode and create a New Project. You'll have the option of choosing one of the Cocos2d-X templates from the iOS category.

原创粉丝点击