coco2d-JS 快速安装

准备工作

下载Cocos2d-JS

Cocos2d-JS 3.0版本

安装python

下载Android SDK Android

下载Android NDK

下载Ant

apache-ant-1.9.6-bin

安装

进入Cocos2d-JS目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
cocos2d-x-3.7  ./setup.py

Setting up cocos2d-x...
->Check environment variable COCOS_CONSOLE_ROOT
->Search for environment variable COCOS_CONSOLE_ROOT...
->COCOS_CONSOLE_ROOT is found : /Users/misael/Desktop/cocos2d-x-3.7/tools/cocos2d-console/bin

->Check environment variable COCOS_TEMPLATES_ROOT
->Search for environment variable COCOS_TEMPLATES_ROOT...
->COCOS_TEMPLATES_ROOT is found : /Users/misael/Desktop/cocos2d-x-3.7/templates

->Configuration for Android platform only, you can also skip and manually edit "/Users/misael/.zshrc"

->Check environment variable NDK_ROOT
->Search for environment variable NDK_ROOT...
->NDK_ROOT not found

->Search for command ndk-build in system...
->Command ndk-build not found

->Please enter the path of NDK_ROOT (or press Enter to skip):
->Check environment variable ANDROID_SDK_ROOT
->Search for environment variable ANDROID_SDK_ROOT...
->ANDROID_SDK_ROOT not found

->Search for command android in system...
->Command android not found

->Please enter the path of ANDROID_SDK_ROOT (or press Enter to skip):
->Check environment variable ANT_ROOT
->Search for environment variable ANT_ROOT...
->ANT_ROOT not found

->Search for command ant in system...
->Command ant not found

->Please enter the path of ANT_ROOT (or press Enter to skip):/Users/misael/Desktop/cocos2d-x-3.7/Android/apache-ant-1.9.6/bin
-> Add ANT_ROOT environment variable...
->Added ANT_ROOT=/Users/misael/Desktop/cocos2d-x-3.7/Android/apache-ant-1.9.6/bin


A backup file "/Users/misael/.zshrc.backup1" is created for "/Users/misael/.zshrc".

Please execute command: "source /Users/misael/.zshrc" to make added system variables take effect

➜ cocos2d-x-3.7 source /Users/misael/.zshrc
➜ cocos2d-x-3.7 cocos new HelloCoco2djs -l js
➜ cocos2d-x-3.7 cocos new HelloCoco2djs -l js
➜ cocos2d-x-3.7 cd ../
➜ Desktop source /Users/misael/.zshrc
➜ Desktop cocos new HelloCoco2djs -l js

编译HTML5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
➜  Desktop  cd HelloCoco2djs
➜ HelloCoco2djs cocos compile -p web -m release
Running command: compile
Building mode: release
running: '/Users/misael/Desktop/cocos2d-x-3.7/Android/apache-ant-1.9.6/bin/ant -f /Users/misael/Desktop/HelloCoco2djs/publish/html5/build.xml'

Buildfile: /Users/misael/Desktop/HelloCoco2djs/publish/html5/build.xml

compile:
[jscomp] Compiling 157 file(s) with 42 extern(s)
[jscomp] 0 error(s), 0 warning(s)

BUILD SUCCESSFUL
Total time: 9 seconds