Setup this Engine is really difficult to many one, because of not simple as running only file setup.exe, then Next, Next, finish. It requires system configuration, and setup auxiliaries for running. And running it also works through an editor program (like Visual Studio).
* Preparing materials, notices: download 32bit or 64bit for OS correspondingly
1) Cocos2d-x http://www.cocos2d-x.org/download.
2) Android platform ( for building apk file of Android ) :
- ADT + free Eclipse:
http://developer.android.com/tools/sdk/eclipse-adt.html
But now, Google does not integrate SDK in Eclipse, so you must download Android Studio instead, here link download
http://developer.android.com/sdk/index.html
- NDK: https://developer.android.com/tools/sdk/ndk/index.html
If use old cocos2d, use NDK r9d: http://dl.google.com/android/ndk/android-ndk-r9d-windows-x86_64.zip
- Notice: Engine v3.3 update to NDK10, fix for Android v5
- NDK 10 :http://developer.android.com/tools/sdk/ndk/index.html
- JDK:
http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html
3) ANT http://ant.apache.org/bindownload.cgi
4) Python 2.x.x ( don't use v3.x ): https://www.python.org/download/
5) Visual Studio 2012 ( Recommend ) + Visual Assist X10.8 http://www.vn-zoom.com/f103/red-face-visual-assist-x-10-8-2001-0-ci-hien-thi-cac-ham-cac-bien-cac-doan-chuong-trinh-mot-cach-ro-rang-2829579.html
Visual Assist X10.8 is Plugin for Auto complete code of Visual studio.
* Notice:
- New version V3.0 - 3.x does not need installing Cygwin as old versions
Step 1: Installing JDK, Python as normal softwares
+ JDK: After installing, it creates a variable in System Environment,
JAVA_HOME = D:\Program Files\Java\jdk1.8.0_25
JDK v7, v8 is OK. Don't use JDK v6
JAVA_HOME = D:\Program Files\Java\jdk1.8.0_25
JDK v7, v8 is OK. Don't use JDK v6
Installing Python 2.7.5 as normal software, It is installed in the path C:\Python27 by default.
NDK, ADT, ANT, Cocos2d-x V3.0 - 3.x only extract into some following folders:
+ ANT: E:/Android/ANT
+ SDK: E:/Android/SDK
+ NDK: E:/Android/NDK
+ Cocos2dx3 : E:/Android/Cocos2dx3
+ With Android Studio, you install as normal, and find the path of SDK.
Running file SDK.exe in E:\ANDROID\SDK, for installing SDK suites of Android, notices that you must install Android v2.3.3 - API 10, it is obligatory, and you can install any other versions, it's up to you.
+ SDK: E:/Android/SDK
+ NDK: E:/Android/NDK
+ Cocos2dx3 : E:/Android/Cocos2dx3
+ With Android Studio, you install as normal, and find the path of SDK.
Running file SDK.exe in E:\ANDROID\SDK, for installing SDK suites of Android, notices that you must install Android v2.3.3 - API 10, it is obligatory, and you can install any other versions, it's up to you.
Step 3: Setup System Variable, VERY IMPORTANT!
- Right click Mycomputer/Properties/Advanced System setting/Environment Variables
In User area, Add some following variables
ANDROID_SDK_ROOT = E:\ANDROID\SDK
COCOS_CONSOLE_ROOT = E:\ANDROID\Cocos2dx3\tools\cocos2d-console\bin;
Path = E:\android\cocos2dx3\tools\cocos2d-console\bin;
*Notice: COCOS_CONSOLE_ROOT and Path will be created after running setup.py ( in step 6)
In System area, Add some following variables
ANT_HOME = E:\ANDROID\ANT
ANT_ROOT = E:\ANDROID\ANT\bin
NDK_ROOT = E:\ANDROID\NDK
Path = C:\Python27;C:\Python27\Python.exe;E:\ANDROID\SDK\sdk\platform-tools;%path%;%ANT_HOME%/bin;
Also add this variable!
CLASSPATH = .;C:\Program Files\Java\jre6\lib\ext\. ( maybe JRE7, or JRE8, remember the mark ".;" at the beginning )
*Notice: The values of above environment variables does not contains space at the beginning or the end
Step 4: Test
Open cmd window, enter the command:
>java
If it runs => JDK is OK
>ant --v
If it runs => ANT is OK
>adb
If it runs => SDK is OK
>python
If version appears => Python is OK
Step 5: Setup Visual Studio 2012 and Visual Assist X 10.8 (Recommended)
- To build on Windows OS, You must install VS 2012 ( or VS 2013 ). Recommended VS2012 Pro or higher.
Step 6: Running
in CMD Window, enter:
D>E:
E>cd android/cocos2dx3
E:/android/cocos2dx>setup.py
If it appears the following, you succeed 99%
Close cmd window
And open cmd again, Now we start using cocos2dx
Create new project
>cocos new hello -p com.vn.hello -l cpp -d e:/android/project
or
>cocos new hello -l cpp -d e:/android/project
It takes about 5 minutes...
Done, now run!
>cocos run -s E:/android/project/hello -p win32
file built is in E:/android/project/hello/bin ( 3.0 ) , E:/android/project/hello/publish (>3.1 )
Your computer must be installed Visual Studio 2012 for running above command
The first time built takes 5 -8 minutes up to each computer, but after that, Edit code and build again is faster
Build for Android, if you installed SDK ( must have android 2.3.3 - API 10) you will succeed.
>cocos compile -s E:/android/project/hello -p android --ap 16
or as follow, it is automatically installed into Emulator
>cocos run-s E:/android/project/hello -p android --ap 16
Done, now run!
>cocos run -s E:/android/project/hello -p win32
file built is in E:/android/project/hello/bin ( 3.0 ) , E:/android/project/hello/publish (>3.1 )
Your computer must be installed Visual Studio 2012 for running above command
The first time built takes 5 -8 minutes up to each computer, but after that, Edit code and build again is faster
Build for Android, if you installed SDK ( must have android 2.3.3 - API 10) you will succeed.
>cocos compile -s E:/android/project/hello -p android --ap 16
or as follow, it is automatically installed into Emulator
>cocos run-s E:/android/project/hello -p android --ap 16
If error, delete --ap 16 as follow:
>cocos run-s E:/android/project/hello -p android
Go to E:\ANDROID\Project\hello\proj.android\bin\debug\android (or folder publish ), run file hello-debug.apk by emulator
>adb install E:/ANDROID/Project/hello/proj.android/bin/debug/android/hello-debug.apk
or you can install apk into real phone for testing
Ok it's done for Cocos2d - x V3.0 Final - 3.x on Windows OS
P/S:
New commands in Cocos2d - x V3.0 FINAL - 3.x (run by cmd window)
Create new other project
cocos new NewProject -p com.vn.NewProject -l cpp -d E:/android/myproject
(enter cocos new -h for help)
Compile
for Android
cocos compile -s E:/android/myproject/NewProject -p android --ap 16
for Windows
cocos compile -s E:/android/myproject/NewProject -p win32
(enter cocos compile -h for help)
Run
cocos run -s E:/android/myproject/NewProject -p win32
cocos run -s E:/android/myproject/NewProject -p android --ap 16
(enter cocos run -h for help)
Other Notices
If built failed with WIN64
Go to E:\ANDROID\Project\hello\proj.android\bin\debug\android (or folder publish ), run file hello-debug.apk by emulator
>adb install E:/ANDROID/Project/hello/proj.android/bin/debug/android/hello-debug.apk
or you can install apk into real phone for testing
Ok it's done for Cocos2d - x V3.0 Final - 3.x on Windows OS
P/S:
New commands in Cocos2d - x V3.0 FINAL - 3.x (run by cmd window)
Create new other project
cocos new NewProject -p com.vn.NewProject -l cpp -d E:/android/myproject
(enter cocos new -h for help)
Compile
for Android
cocos compile -s E:/android/myproject/NewProject -p android --ap 16
for Windows
cocos compile -s E:/android/myproject/NewProject -p win32
(enter cocos compile -h for help)
Run
cocos run -s E:/android/myproject/NewProject -p win32
cocos run -s E:/android/myproject/NewProject -p android --ap 16
Other Notices
If built failed with WIN64
- If installed VS 2010 in previous and then remove it, its registry is still in 64bit. First you uninstall vs2010 and then go to regedit and go to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft Deletei VisualStudio key, then go to: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft find and delete VisualStudio key, Then installing vs2012 or vs2013 and OK ^^
- If built failed in Android:
Use command cd to project and run
cocos run -p android -j 4
It's done!
Follow Source: http://laptrinhgamecocos2dx.blogspot.com/
Source Link: http://laptrinhgamecocos2dx.blogspot.com/2014/04/bai-3-huong-dan-cai-dat-cocos2d-x-v3-tren-win-dow.html
[ttaiit.blogspot.com translated]
0 comments:
Post a Comment