ผลต่างระหว่างรุ่นของ "01219245/cocos2d-js/installation/3.2"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
 
(ไม่แสดง 8 รุ่นระหว่างกลางโดยผู้ใช้คนเดียวกัน)
แถว 1: แถว 1:
: ''This is part of [[01219245]].''
+
: ''This is part of [[01219245-57]].''
  
 
[http://cocos2d-x.org/products#cocos2dx-js Cocos2d-JS] comes with a console tool to create new projects and run as a web server for your game.
 
[http://cocos2d-x.org/products#cocos2dx-js Cocos2d-JS] comes with a console tool to create new projects and run as a web server for your game.
  
 
== Requirements ==
 
== Requirements ==
* Python
+
=== Python 2 ===
 +
The console tool for cocos2d-js uses python. 
 +
 
 +
'''Linux/Mac''': If you are running Linux or Mac, you should be fine with this step.  However, you can make sure that you are running the right version of python, by calling
 +
 
 +
python --version
 +
 
 +
and see that the version is 2.x.x
 +
 
 +
'''Windows''': If you are using Windows, please install python.  You can go to [https://www.python.org https://www.python.org] to download.  '''MAKE SURE THAT YOU GET VERSION 2.7.x''', as Cocos2d-JS does not work with Python3.
 +
 
 +
After you installed Python, it will be nice to set the path on your machine so that you can call <tt>python</tt> from the command line.  Ask our TAs for this help.
 +
 
 +
== Download Cocos2d-JS and install ==
 +
Download Cocos2d-JS 3.2 from: [http://www.cocos2d-x.org/filedown/cocos2d-js-v3.2.zip Cocos2d website], or [http://theory.cpe.ku.ac.th/~jittat/cocos/cocos2d-js-v3.2.zip mirror] (should be faster).
 +
 
 +
Unzip the zip file to where you want to keep the framework's files.
 +
 
 +
Change directory to where you unzipped the files.  Then call
 +
 
 +
python setup.py
 +
 
 +
And that's it.
  
 
== Checking the installation ==
 
== Checking the installation ==
แถว 13: แถว 35:
  
 
<pre>
 
<pre>
/xxxx/cocos.py 1.5 - cocos console: A command line tool for cocos2d-x
+
/xxxx/cocos2d-js-v3.2/tools/cocos2d-console/bin/cocos.py 1.5 - cocos console: A command line tool for cocos2d-x
  
 
Available commands:
 
Available commands:
แถว 28: แถว 50:
  
 
Example:
 
Example:
/home/jittat/prog/cocos-js/cocos2d-js-v3.2/tools/cocos2d-console/bin/cocos.py new --help
+
/xxxxx/cocos2d-js-v3.2/tools/cocos2d-console/bin/cocos.py new --help
/home/jittat/prog/cocos-js/cocos2d-js-v3.2/tools/cocos2d-console/bin/cocos.py run --help
+
/xxxxx/cocos2d-js-v3.2/tools/cocos2d-console/bin/cocos.py run --help
 
</pre>
 
</pre>
  
แถว 44: แถว 66:
  
 
=== A sample HelloWorld page ===
 
=== A sample HelloWorld page ===
 +
Cocos2d-JS comes with a sample application when you create a new app.  Find a temporary location and call
 +
 +
cocos new -l js --no-native hello
 +
 +
The script will create a directory '''hello'''.  We can run the app there.
 +
 +
cd hello
 +
cocos run -p web

รุ่นแก้ไขปัจจุบันเมื่อ 08:03, 8 กุมภาพันธ์ 2559

This is part of 01219245-57.

Cocos2d-JS comes with a console tool to create new projects and run as a web server for your game.

Requirements

Python 2

The console tool for cocos2d-js uses python.

Linux/Mac: If you are running Linux or Mac, you should be fine with this step. However, you can make sure that you are running the right version of python, by calling

python --version

and see that the version is 2.x.x

Windows: If you are using Windows, please install python. You can go to https://www.python.org to download. MAKE SURE THAT YOU GET VERSION 2.7.x, as Cocos2d-JS does not work with Python3.

After you installed Python, it will be nice to set the path on your machine so that you can call python from the command line. Ask our TAs for this help.

Download Cocos2d-JS and install

Download Cocos2d-JS 3.2 from: Cocos2d website, or mirror (should be faster).

Unzip the zip file to where you want to keep the framework's files.

Change directory to where you unzipped the files. Then call

python setup.py

And that's it.

Checking the installation

Cocos command line

Try calling cocos from the command line. You should see:

/xxxx/cocos2d-js-v3.2/tools/cocos2d-console/bin/cocos.py 1.5 - cocos console: A command line tool for cocos2d-x

Available commands:
	run           Compiles & deploy project and then runs it on the target
	luacompile    minifies and/or compiles lua files
	deploy        Deploy a project to the target
	compile       Compiles the current project to binary
	new           Creates a new project
	jscompile     minifies and/or compiles js files

Available arguments:
	-h, --help	Show this help information
	-v, --version	Show the version of this command tool

Example:
	/xxxxx/cocos2d-js-v3.2/tools/cocos2d-console/bin/cocos.py new --help
	/xxxxx/cocos2d-js-v3.2/tools/cocos2d-console/bin/cocos.py run --help

Running a sample game

Change directory into samples/js-moonwarriors

cd samples/js-moonwarriors

Then call

cocos run -p web

The script will start a web server at your machine. Now you can point your browser to: http://127.0.0.1:8000/samples/js-moonwarriors/ to start playing MoonWarriors.

A sample HelloWorld page

Cocos2d-JS comes with a sample application when you create a new app. Find a temporary location and call

cocos new -l js --no-native hello

The script will create a directory hello. We can run the app there.

cd hello
cocos run -p web