cocos2d-x 3.x游戏开发学习笔记(1)--mac下配置cocos2d-x 3.x开发环境

来源:互联网 发布:计步器软件哪个好用 编辑:程序博客网 时间:2024/06/02 08:46

原文:http://blog.csdn.net/likendsl/article/details/34617725

打开用户目录下.bash_profile文件,配置环境 

[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. vim ~/.bash_profile //按键i,进行插入编辑(如果输错d进行删除一行)  

环境配置步骤如下:

1、首先配置下android sdk,我的是在opt目录下

[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. #sdk  
  2. export ANDROID_SDK_ROOT=/opt/android-sdk-macosx  
  3. export PATH=$PATH:$ANDROID_SDK_ROOT  
  4. export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools  

2、ndk 

[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. #ndk  
  2. export NDK_ROOT=/opt/android-ndk-r9b  
  3. export PATH=$PATH:$NDK_ROOT  

3、ant 

[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. #ant  
  2. export ANT_ROOT=/opt/apache-ant-1.9.3/bin  
  3. export PATH=$PATH:$ANT_ROOT  

等一切都配置好之后,我们现在就应该到终端下cocos2d-x3.0的目录下执行以下命令:

[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. ./setup.py  

执行过之后终端会显示以下内容

[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. ???mcbookpro:cocos2d-x-3.0$ ./setup.py   
  2.   
  3. Setting up cocos2d-x...  
  4. ->Check environment variable COCOS_CONSOLE_ROOT  
  5.   ->Find environment variable COCOS_CONSOLE_ROOT...  
  6.     ->COCOS_CONSOLE_ROOT is found : /Project/cocos2d-x-3.0/tools/cocos2d-console/bin  
  7.   
  8. ->Configuration for Android platform only, you can also skip and manually edit "/Users/你的用户名/.bash_profile"  
  9.   
  10. ->Check environment variable NDK_ROOT  
  11.   ->Find environment variable NDK_ROOT...  
  12.     ->NDK_ROOT is found : /opt/android-ndk-r9b  
  13.   
  14. ->Check environment variable ANDROID_SDK_ROOT  
  15.   ->Find environment variable ANDROID_SDK_ROOT...  
  16.     ->ANDROID_SDK_ROOT is found : /opt/android-sdk-macosx  
  17.   
  18. ->Check environment variable ANT_ROOT  
  19.   ->Find environment variable ANT_ROOT...  
  20.     ->ANT_ROOT is found : /opt/apache-ant-1.9.3/bin  
  21.   
  22.   
  23. Please execute command: "source /Users/你的用户名/.bash_profile" to make added system variables take effect  

如果出现以上内容我们的配置就成功了,你到你的 /Users/你的用户名/.bash_profile文件中看一下,会默认为我们添加以下两行代码

[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. # Add environment variable COCOS_CONSOLE_ROOT for cocos2d-x  
  2. export COCOS_CONSOLE_ROOT=/Project/cocos2d-x-3.0/tools/cocos2d-console/bin  
  3. export PATH=$COCOS_CONSOLE_ROOT:$PATH  

这时候你再重启或执行以下代码:

[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. source /Users/你的用户名/.bash_profile  

执行完成后没有任何提示,没关系,linux下没有消息,就是好消息。

完成以上之后,你在终端下敲以cocos new 命令,你会惊奇的发现

[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. mcbookpro:cocos2d-x-3.0$ cocos new  
  2. Runing command: new  
  3. usage: cocos new [-h] [-p PACKAGE_NAME] -l {cpp,lua,js} [-d DIRECTORY]  
  4.                  [-t TEMPLATE_NAME] [--no-native]  
  5.                  [PROJECT_NAME]  
  6. cocos new: error: argument -l/--language is required  
你可以敲以下命令创建自己的工程:

[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. cocos new WXYCocosTemplate -p com.game.study -l cpp -d /Users/more2010wei/Documents/more2010wei/cocos2dproj/  

参数说明如下:
[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. WXYCocosTemplate//工程名    
  2. -p 后跟你的包名   
  3. -l cpp  这是一个cpp工程  
  4. -d 后跟的是你要建的工程路径   

命令执行完之后终端下出现:

[python] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. Runing command: new  
  2. > Copy template into /Users/more2010wei/Documents/more2010wei/cocos2dproj/WXYCocosTemplate  
  3. > Copying cocos2d-x files...  
  4. > Rename project name from 'HelloCpp' to 'WXYCocosTemplate1'  
  5. > Replace the project name from 'HelloCpp' to 'WXYCocosTemplate1'  
  6. > Replace the project package name from 'org.cocos2dx.hellocpp' to 'com.game.study'  

配置到现在就完成了,开始享受游戏开发的乐趣吧。


0 0
原创粉丝点击