01219245/cocos2d chrome setup

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา

If you want to use Chrome to view local Cocos2d-html5 applications, follow these steps.

Many of these instructions are from Manatsawin. Thanks again.

Notes: Chrome also caches your JavaScript files. To disable JavaScript caching, set the option in the Developer Tool (Go to: Settings -> General -> Disable cache (while DevTools is open).)

Chrome-cache-disable.png

Option 1: User Python build-in server for Linux, Mac and (Windows user with Python)

Most Linux and Mac comes with Python so this might be the easiest way. If you use Windows and have Python installed, this might be a good way for you too.

For Linux & Mac: You just open a terminal, change directory to the Cocos2d-html5 directory, and call

python -m SimpleHTTPServer

For Windows with Python installation, change python to python.ext.

The current directory will be available at http://localhost:8000/, so if you want to view the game try something like: http://localhost:8000/mygames/tutorial1/

Option 2: Use Mongoose as a web server

This option is fairly easy for Windows users. Mongoose is a light-weight web server. You can download the windows version from this download page. You'll have to provide your name and email. Pick the free version.

You can download it and save it in any directory. To run the web server, open the command line cmd.exe, change directory to where Cocos2d-html is, then call

PATHTOMONGOOSE\mongoose-free-5.2.exe

where PATHTOMONGOOSE is the path to where you have installed Mongoose.

The directory of Cocos2d-html will be available as http://localhost:8080/

You can also configure Mongoose by clicking at its icon in the taskbar.

Option 3: Run Chrome with web security disabled

Notes Don't do this for your normal web surfing.

You'll have to run Chrome from the command line:

  • Linux:
google-chrome-stable --disable-web-security 

(or chromium --disable-web-security)

  • Mac:
open -a Google\ Chrome --args --disable-web-security
  • Windows: You have to edit chrome shortcut and add --disable-web-security behind the application target. (If you ever try opening console in Half-Life before Steam, it is the same way)

Other options

You can host your game at KU's pirun server.