如何在Xcode平台上安装并创建新的cocos2d-x项目

如何把著名的Cocos2dSimpleGameobjc 移植到Xcode上,通过使用cocos2d-x引擎,在iPhone平台上运行它。Cocos2dSimpleGame是由Ray Wenderlich编写。几乎所有的cocos2d-iphone初学者都曾读过他写的系列教程。

首先,你需要在http://download.cocos2d-x.org/ 下载最新稳定版的cocos2d-x20121024日查阅,该版本还是cocos2d-2.0-x-2.0.3.zip

Stable versions 20121024日查阅如下:

1. Cocos2d-x

written in C++ and OpenGL ES 1.1/2.0, run on iOS, Android, BlackBerry, Bada, Marmalade, Windows, Linux and more

·         cocos2d-2.0-x-2.0.3 @ Sep 26 2012 (这是我要下载的cocos2d-2.0-x-2.0.3.zip文件114M

o    update CCBReader to v2.1 beta0, add CCTableView, update CCControlExtension, more stable javascript binding, enhance lua binding, more elegant java lib codes, many bugs fixed

·         cocos2d-2.0-x-2.0.2 @ Aug 30 2012

o    add mac port, linux port, blackberry port, multi-resolution support, implement CCEditBox, network wrapper, many bugs fixed

·         ccocos2d-1.0.1-x-0.13.0-beta @ Mar 29, 2012

o    support new iPad, simplify Android.mk written, accelerometer simulation for iOS simulator, some bugs fix

·         cocos2d-1.0.1-x-0.12.0 @ Mar 05, 2012

o    support bb2.0, add CCNotificationCenter, refactor lua support, more stable on Andorid, bada and QNX when using dynamic_cast, Android template supports box2d, chipmunk and lua, some crash fix

2. Cocos2d-html5

written in javascript, based on HTML5 technology. This branch focus on desktop browsers

·         Cocos2d-html5-v2.0.0 @ Aug.28, 2012

·         Cocos2d-html5-v0.5.0-alpha2 @ Jun.18, 2012

3. Cocos2d-XNA

written in C#, base on XNA rendering, for Windows Phone 7

·         cocos2d-x-for-xna-0.1.0 @ Feb 17, 2012

o    Considering Windows Phone 7 doesn't open C++ api and has no OpenGL ES support, so we ported cocos2d-x into C# and using their XNA renderer.

o    Special thanks to OpenXLive.com, they have contributed lots of source code to this port.

More historical versions:

·         Please visit http://code.google.com/p/cocos2d-x/downloads/list for more historical versions.

下载后解压后的文件如下:

如何在Xcode平台上安装并创建新的cocos2d-x项目


其次是要安装对应的Xcode的模板。我们从0.8.2版开始就有了对应Xcode的模板。你可以像创建cocos2d-iphone项目那样简单地来创建cocos2d-x项目。首先,找到cocos2d-x的根目录,之后在macshell下运行install-templates.sh (注意不要少了” ./”)./install_template.sh。之前网上有介绍用这个带参数的命令“./install-templates-xcode.sh -u –f”,经测试这样是不行的。而是要用不带参数的命令“./install-templates-xcode.sh ”。(注:这样就可以了!20121024日)见下图:

如何在Xcode平台上安装并创建新的cocos2d-x项目
--------------------------------------------------------------------------------------

  Last login: Wed Oct 24 19:24:21 on console
DantekiMacBook-Pro:~ dans88$ ls
Desktop        Documents    Downloads    Library        Movies        Music        Pictures    Public
DantekiMacBook-Pro:~ dans88$ cd Desktop
DantekiMacBook-Pro:Desktop dans88$ ls
Beginning Passbook in iOS 6.doc        Resources                iOS6新特征lout编程指南.doc
Firefox-latest.dmg            SonyDevice                install_flash_player_osx.dmg
Kexts                    Sony_bak                myHack-3.1.2.dmg
QQInput_Mac_Setup_2_3_42_400.dmg    cocos2d
QQ_V2.1.3.dmg                cocos2d-x
DantekiMacBook-Pro:Desktop dans88$ cd cocos2d
DantekiMacBook-Pro:cocos2d dans88$ ls
AUTHORS                cocos2d-win32.vc2010.sln    create-blackberry-project.vbs    licenses
CHANGELOG            cocos2d-win32.vc2012.sln    document            make-all-linux-project.sh
CocosDenshion            cocos2dx            extensions            samples
README.mdown            create-android-project.bat    external            scripting
build-win32.bat            create-android-project.sh    install-templates-msvc.bat    template
cocos2d-win32.vc2008.sln    create-blackberry-project.sh    install-templates-xcode.sh    tools
DantekiMacBook-Pro:cocos2d dans88$ sudo ./install-templates-xcode.sh
Password:*****
cocos2d-x template installer

Installing Xcode 4 cocos2d-x iOS template
----------------------------------------------------

...creating destination directory: /Users/dans88/Library/Developer/Xcode/Templates/cocos2d-x/
...copying cocos2d files
...copying CocosDenshion files
...copying extension files
...copying template files
done!

Installing Xcode 4 Chipmunk iOS template
----------------------------------------------------

...copying Chipmunk files
done!

Installing Xcode 4 Box2d iOS template
----------------------------------------------------

...copying Box2D files
done!

Installing Xcode 4 lua iOS template
----------------------------------------------------

...copying lua files
done!

Installing Xcode 4 JS iOS template
----------------------------------------------------

...copying js files
done!
...copying spidermonkey files
done!
done!
DantekiMacBook-Pro:cocos2d dans88$
------------------------------------------------------

经测试,我的系统有三个Xcode版本,Xcode 4.4 、Xcode 4.5Xcode 4.5.1在安装一次以后,三个版本都可以用!
安装完成之后,你就可以打开Xcode,之后点击“Creat a new Xcode project”。你会看到这个对话框

如何在Xcode平台上安装并创建新的cocos2d-x项目

选择“cocos2d-x application”,之后点“choose”,输入项目的名称。

如何在Xcode平台上安装并创建新的cocos2d-x项目

Xcode将会帮你创建好cocos2d-x的项目。

如何在Xcode平台上安装并创建新的cocos2d-x项目

请注意,iOScocos2d-x项目可以在任何你想要的地方被创建。Xcode里的wizard会复制所有cocos2dxCocosDenshion等库到项目的文件夹里。这和VisualStudiowin32&Phonewizard不同。

好了,之后编译运行,你会看到如下的HelloWorld效果图

如何在Xcode平台上安装并创建新的cocos2d-x项目

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值