This tutorial covers the process of getting Cocos2D-html setup and running. If you
Already have completed this step, Skip ahead. It is also going to cover processing a webserver, an optional (but relatively easy) Step. All right, lets get started.
First thing you need to do is get the cocos2d-html5 sources, which you can
Download HERE.
Locate the zip icon, as demonstrated in the picture to your left, click it.
Save the resulting download anywhere, just remember where you save it, we will need it in a few moments.
Now we are going to install a webserver. this part is strictly optional, but if you want to take full advantage of the Cocos demos, you are going to want a webserver installed. it will also allow you to access your creation from different machines. besides,
It's a fairly simple process. These instructions are for Windows only.
Now head over to Wamp and download their server. the Wamp Server is an all in one install of Apache, MySQL, PHP and a few other applications, in every ways it is complete overkill, but like I said, it's easy.
Pick whichever version is most appropriate, it doesn' t really matter which, so long as you choose the right one for your processor (32 or 64 bit ).
Now run the installer. I choose the default value for every entry and let it install to c: \ Wamp. if you saved to a different directory, adjust your path's accordingly later on in this tutorial. it is going to ask you to pick your default browser and default
Out to assumer.exe (the shell, not to be confused with Internet Explorer the browser ). you can explain icitly choose a browser if you want but there is little reason to do so. when prompted for mail settings, simply take the default. wamp Server will now
Be installed and running in your system tray.
Like such. Left clicking the tray icon will bring up the menu shown above. Click localhost to see your webserver in action.
If everything went according to plan, you shoshould see:
Now we want to extract the cocos2d-html archive we downloaded earlier. Open up the zip and navigate the folders until you find a directory that looks like such:
CTRL + A select the entire contents of this folder in the zip and paste it to C: \ Wamp \ www \.
Now in your browser, you shocould be able to navigate to localhost/index.html and you will see:
If so, congrats, you have successfully set up cocos2d for html5. if not, make sure you have the proper contents in c: \ Wamp \ www, and that it's not buried in a subdirectory. now optionally you can open access to it up a bit so other computers on your network
Can see the website. I am by no means an Apache expert (was born and raised on IIS), so do not take this as authoritative in any way!
You want to edit httpd. conf, which you can do from the tray icon, like such:
Find and locate the following entries to match what I 've done here (with your IP address obviusly ):
Set your IP and port to listen on, entry was originally listen 80:
## Listen: Allows you to bind Apache to specific IP addresses and/or# ports, instead of the default. See also the <VirtualHost># directive.## Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses.#Listen 192.168.2.103:80
Set the server name to your servers name, or if you haven't got DNS configured (such as yourserver.yourname.com) Use your IP address like I have:
## ServerName gives the name and port that the server uses to identify itself.# This can often be determined automatically, but we recommend you specify# it explicitly to prevent problems during startup.## If your host doesn't have a registered DNS name, enter its IP address here.#ServerName 192.168.2.103
Finally, grant access to your WWW Folder:
<Directory "c:/wamp/www/"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride all # # Controls who can get stuff from this server. ## onlineoffline tag - don't remove Order Allow,Deny Allow from all</Directory>
You shoshould now have full access to your webserver folder from other machines on your network (and externally if you don't have a firewall or have port forwarding configured ). you can of course tweak the Security Settings until the cows come home.
Now, save your changes and restart your Apache server, this can again be done from the tray icon, simply left click and choose restart all services. if your icon doesn't turn green, you have made an error in the httpd. CONF file.
Again, the entire server portion is optional, you can just work from the local file system, but this allows you to make use of the full demo and test suite.
Speaking of which, if you now open your browser
Http: // yourserverip/tests/index.html you shoshould now have access to all the varous cocos2d tests, like such:
Now you are set up and ready to go. In the next tutorial, we will actually get to some coding.