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 oolsproject-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.4projects".

1.3 [Develop game in Visual Studio]: Open "X:...cocos2d-x-2.2.4projectsMyGameproj.win32MyGame.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:cygwinin"
1.4.3 Add line to "X:Cygwinetcfstab" 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.4cocos2dxplatformandroidjava"

1.7 [Import your game project]: Import your game project from "X:...cocos2d-x-2.2.4projectsMyGameproj.android"

1.8 Debug or run your game

2. Problems

2.1 [undefined reference to 'MainMenu::scene()']
In "X:...cocos2d-x-2.2.4projectsMyGameproj.androidjniAndroid.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.4projectsMyGameproj.androidREADME.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)

原文地址:https://www.cnblogs.com/chenyineng/p/3828947.html