Start with Cocos2DX Lua, this set up an environment surprisingly so many, online check feeling too messy, tidy up yourself! Visual Studio 2015, BabeLua, Python, Cocos2dx, JDK, Android NDK, Android SDK, Ant

Environment configuration

  1. Download and install Visual Studio 2015 at http://msdn.itellyou.cn/ Visual Studio Community 2015 (x86) -DVD (Chinese-Simplified) > Download and install Visual Studio Community 2015 (x86) -DVD (Chinese-Simplified)

2. Configure BabeLua (vs2015 programming Lua plug-in) For 2015 V3.2.2.0

  • After downloading, double-click Install and restart Visual Studio 2015. The Lua menu appears in the main menu

3. Configure the JDK, http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  • Double click on the install
  • Configure Java environment variables: My computer > Right-click > Properties > Advanced System Settings > Advanced > Environment Variables
  • Click newThe variable name:JAVA_HOME Variable values (JDK directory) :D: \ \ Program Files \ Java \ jdk1.8.0 _131
  • Click newThe variable name:CLASSPATH A variable’s value:.; %JAVA_HOME%\lib\dt.jar; %JAVA_HOME%\lib\tools.jar;
  • Double-click Path to add value (append) :; %JAVA_HOME%\bin; %JAVA_HONE%\jre\bin

4. To configure the NDK, https://developer.android.google.cn/ndk/downloads/index.html?hl=zh-cn

  • Find a place to unzip it
  • Configure environment variables (open in previous steps)
  • Click newThe variable name:NDK_ROOT Variable value (NDK decompressed directory) :D:\Android\android-ndk-r14b

5. Configure the Android SDK, http://dl.google.com/android/android-sdk_r24.3.4-windows.zip

  • Find a place to unzip it
  • Open the directorySDK Manager.exeDownload platform-tools and some SDK platforms
  • Configure environment variables (open in previous steps)
  • Click newThe variable name:ANDROID_SDK_ROOT Variable value (android SDK decompressed directory) :D:\Android\android-sdk
  • Double-click Path to add value (append) :; %ANDROID_SDK_ROOT%\platform-tools; %ANDROID_SDK_ROOT%tools

6. Configure Ant, http://ant.apache.org/bindownload.cgi

  • Find a place to unzip it
  • Configure environment variables (open in previous steps)
  • Click newThe variable name:ANT_ROOT Variable value (Ant unzipped directory) :D: \ \ Program Files \ apache ant -- 1.10.1

7.Python, Windows x86 Installer (2.7.0) (SIG)

  • Double click on the install
  • Configure environment variables (open in previous steps)
  • Double-click Path to add value (append Pythone installation directory) :; C:\Python27

8. Download Cocos2dx, cocos2D-X-3.15.zip

  • Download and unzip to the appropriate location
  • Go to the root directory of cocos2D-x and double-click setup.py


Start project

  1. cmdCreate Cocos2dx Lua project:Cocos new project name -p Package name -L lua -d Project directory -- no-native
-p package name-lLanguage-no-native do not run environmentsCopy the code
Example: E:\Cocos2dProject>cocos new OneDemo-l lua -dWhen developing using the Cocos command-line tool, Cocos collects usage data for the development environment. This data is only used for summary analysis and continuous innovation and improvement of Cocos products. The collected data is anonymous and located at the development end only, including but not limited to: unique device identification, software version number, coCOs-related tool products and use of specific features. We will keep your personal information strictly confidential and will never share or sell this data. You can choose not to share this data, but you can help Cocos grow by sharing this data. Do you agree to send the data? [Y] Agree, [N] Disagree Y > Copy template to E:\Cocos2dProject\OneDemo > replace project name in file,'HelloLua'Replace with'OneDemo'. > Folder in copy engine... > Copy the folder in the template... > copy cocos2d-x... > Folder in copy engine... > replace the project name in the filename,'HelloLua'Replace with'OneDemo'. > replace the project name in the file,'HelloLua'Replace with'OneDemo'. > replace the package name of the project,'org.cocos2dx.hellolua'Replace with'org.cocos2dx.OneDemo'. > replace the Bundle ID of the Mac project'org.cocos2dx.hellolua'Replace with'org.cocos2dx.OneDemo'. > replace the iOS project Bundle ID.'org.cocos2dx.hellolua'Replace with'org.cocos2dx.OneDemo'. E:\Cocos2dProject>Copy the code

Openonedemo. SLN: E:\Cocos2dProject\OneDemo\frameworks\ Runtime-src \proj.win32 Install the missing program according to the prompt, and restart the computer after installation.

3. Compile and run… After compiling, open oneDemo.exe in the new simulator\win32 directory in the project directory

4. Create Lua project on VS2015 (OneDemo is the project directory)

5.Lua Project Directory



The cocos2D-x-3.15 log command window does not appear

Go to the project directory: frameworks\runtime-src\proj.win32 open simulatorwin. CPP and change the value of SIMULATOR_WITH_CONSOLE_AND_MENU to 1 as follows:

// define 1 to open console ui and setup windows system menu, 0 to disable
#define SIMULATOR_WITH_CONSOLE_AND_MENU 1
Copy the code


Write code using Sublime Text3

  • Open the current Lua project directory: File > Open Folder… And then select the current project directory
  • Tools > Build System > New Build Systems… Clear the contents and edit them as follows
{ 
	"cmd": [""]."working_dir": "E:\\Cocos2dProject\\OneDemo"."shell": true."encoding":"utf-8"."variants": [{"name": "Run"."cmd" : ["E:\\Cocos2dProject\\OneDemo\\simulator\\win32\\OneDemo.exe"]]}}Copy the code
  • Working_dir: indicates the project directory
  • The CMD below fills the virtual machine directory
  • Run: Ctrl + B