Develop Android Game Using Cocos2d-x
0. Environment
Windows 7 x64
Visual Studio 2013
adt-bundle-windows-x86 (http://developer.android.com/sdk/index.html)
android-ndk-r8e
Python 2.7.3
cocos2d-x-2.2.4
1. Steps
1.1 Install Python, Cocos2d-x, Eclipse ADT bundle, NDK. And add environment variables "Path" with value "X:\Python27"
1.2 [Create Project]: In "X:\...\cocos2d-x-2.2.4\tools\project-creator" folder, using command line to create a project.
create_project.py -project MyGame -package com.MyCompany.AwesomeGame -language cpp
The new project can be found in folder "X:\...\cocos2d-x-2.2.4\projects".
1.3 [Develop game in Visual Studio]: Open "X:\...\cocos2d-x-2.2.4\projects\MyGame\proj.win32\MyGame.sln" to develop your game.
1.4 [Install and set up Cygwin]:
1.4.1 Install Cygwin with packages: autoconf, automake, binutils, gcc-core, gcc-g++, gcc4-core, gcc4-g++, gdb, pcre, pcre-devel, gawk, make.
1.4.2 Add environment variables "Path" with value "X:\cygwin\bin"
1.4.3 Add line to "X:\Cygwin\etc\fstab" file
none /cygdrive cygdrive binary,noacl,posix=0,user 0 0
1.5 [Set up Eclipse environment]:
1.5.1 In "Window->Preferences->General->Workspace->Linked Resources" add a Path Variable "COCOS2DX" pointing to the root cocos2d-x directory "X:\...\cocos2d-x-2.2.4"
1.5.2 In "Window->Preferences->C/C++->Build->Environment" add a variable "NDK_ROOT" pointing to the root NDK directory "X:\...\android-ndk-r8e", and add new variables "CYGWIN" with value "nodosfilewarning" and "SHELLOPTS" with value "igncr"
1.6 [Import libcocos2dx]: Import a project "libcocos2dx" from "X:\...\cocos2d-x-2.2.4\cocos2dx\platform\android\java"
1.7 [Import your game project]: Import your game project from "X:\...\cocos2d-x-2.2.4\projects\MyGame\proj.android"
1.8 Debug or run your game
2. Problems
2.1 [undefined reference to 'MainMenu::scene()']
In "X:\...\cocos2d-x-2.2.4\projects\MyGame\proj.android\jni\Android.mk", add new scenes cpp file to LOCAL_SRC_FILES, for example:
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/MainMenuScene.cpp \
../../Classes/IntroductionScene.cpp
3. References
[1] http://www.cocos2d-x.org/docs/manual/framework/native/v2/getting-started/setting-up-development-environments/windows-7-environment-setup/how-to-set-up-the-android-cocos2d-x-development-environment-on-windows7/zh
[2] cocos2d-x-2.2.4\projects\MyGame\proj.android\README.md
(This article is from http://www.cnblogs.com/chenyineng/p/3828947.html, and belongs to http://chenyineng.cnblogs.com and http://www.chenyineng.info)