(1) Use terminal commands to open the. bash_profile file, command: Open. Bash_profile (Enter)
After opening the file, configure the Android SDK, Ant, NDK and other environment variables, my in the Android directory, so configured as follows (for the directory, for reference only):
# sdkexport Android_sdk_root=android/android-sdk-macosxexport PATH=$PATH: $ANDROID _sdk_ Rootexport PATH= $PATH: $ANDROID _sdk_root/platform-tools# ndkexport ndk_root=android/android-ndk- R9dexport PATH=$PATH: $NDK _root# antexport ant_root=android/apache-ant-1.9. 5 Export PATH=${path}:${ant_root}/bin
(2) Using terminal commands, enter the Cocos2d-x 3.x directory, because I novice, so the method is to use: Open the terminal command, enter the CD, then the space, and then drag the directory directly into the terminal window, and then click the ENTER key.
After entering, reenter the input command:. setup.py (Enter), which appears similar to the following:
Setting up cocos2d-x ...-Check environment variable Cocos_console_root->search forenvironment variable Cocos_console_root ...-Cocos_console_root not found-ADD cocos_console_root environment variable ...->added cocos_console_root=cocos2d-x-3.x/tools/cocos2d-console/bin-Check environment variable Cocos_x_root->search forenvironment variable Cocos_x_root ...-Cocos_x_root not found-ADD cocos_x_root environment variable ...->added cocos_x_root=Documents-Check environment variable Cocos_templates_root->search forenvironment variable Cocos_templates_root ...-Cocos_templates_root not found-ADD cocos_templates_root environment variable ...->added cocos_templates_root=cocos2d-x-3.x/Templates->configuration forAndroid platform only, you can also skip and manually edit"/user/User name/. Bash_profile"-Check environment variable Ndk_root->search forenvironment variable Ndk_root ...->ndk_root isfound:android/android-ndk-r9d-Check environment variable Android_sdk_root->search forenvironment variable Android_sdk_root ...->android_sdk_root isfound:android/android-sdk-MacOSX-Check environment variable Ant_root->search forenvironment variable Ant_root ...->ant_root isfound:android/apache-ant-1.9.5A backup File"/users/user name/.bash_profile.backup1" isCreated for "/users/user name/.bash_profile". Please execute command:"source/users/user name/.bash_profile"To make added system variables take effect
Use setup.py its essence is in your. Bash_profile for you to configure the path of Cocos_console_root,cocos_x_root,cocos_templates_root, you can view your. Bash_ Profile to see the difference, as follows:
# ADD environment variable cocos_console_root for cocos2d-xexport cocos_console_root =/users/user name/documents/cocos2d-x-3.x / Tools/cocos2d-console/binexport PATH = $COCOS _ Console_root: $PATH # ADD environment variable cocos_x_root for cocos2d-< Span style= "color: #000000;" >xexport cocos_x_root =/users/user name/documentsexport PATH = $COCOS _x_root: $PATH # ADD environment variable cocos_templates_root for Cocos2d-xexport cocos_templates_root =/users/user name/documents/cocos2d-x-3.x /templatesexport PATH = $COCOS _templates_root: $PATH
(3) Then open the new Terminal command, enter the command: Cocos new (enter), if it appears as shown below, the configuration is OK
New [-h] [-P package_name] [-D DIRECTORY] [-t Template_name] [--ios-bundleid Ios_bundleid] [--mac-Bundleid Mac_bundleid] [-E Engine_path] [--portrait] [--no- Native] (-L {CPP,LUA,JS} | --list-templates | -k template_name) new is required
(4) To create a case project, you can enter such a command:
New Newversion-p com.demo.org-l cpp-d/users/user name/documents/cocos2d-x-3.x/projects// NewVersion: On behalf of your project name / / - P com.demo.org on behalf of your package name // - D ... Represents your project path
The procedure that executes, if it appears similar to the following, indicates success
> Copy template to/users/user name/documents/cocos2d-x-3. x/projects/Vesiondemo> Copy cocos2d-x ...> Replace the project name in the file name,'Hellocpp'Replaced by'newvesion'. > Replace the project name in the file,'Hellocpp'Replaced by'Newvesiondemo'. > Replace the package name of the project,'Org.cocos2dx.hellocpp'Replaced by'com.demo.org'. > Replace the Bundle ID of the MAC project,'Org.cocos2dx.hellocpp'Replaced by'com.demo.org'. > Replace the Bundle ID of the IOS project,'Org.cocos2dx.hellocpp'Replaced by'com.demo.org'。
Above, is their own personal summary, the approximate process is so, I hope to have help, thank you!
MAC Cocos2d-x 3.x Version Environment configuration