HTML and CSS Reference
In-Depth Information
The ant tool will be executed with build.xml , and it will call the Google closure compiler to release the file
HalloweenDefence.js in the same folder. Then you can configure the project to load this single file.
There are two loading modes in Cocos2d.js . What you need to do is to delete the “delete section” and
uncomment the commented section. Read the comments in Listings 24-23 and 24-24 carefully.
Listing 24-23. Multi-File Loading Mode in cocos2d.js
window. addEventListener ( 'DOMContentLoaded' , function ( ) {
//first load engine file if specified
var s = d.createElement ( 'script' ) ;
/*********Delete this section if you have packed all files into one*******/
if ( c.SingleEngineFile && ! c.engineDir ) {
s.src = c.SingleEngineFile ;
}
else if ( c.engineDir && ! c.SingleEngineFile ) {
s.src = c.engineDir + 'platform/jsloader.js' ;
}
else {
alert ( 'You must specify either the single engine file OR the engine directory in "Cocos2d.
js"' ) ;
}
/*********Delete this section if you have packed all files into one*******/
//s.src = 'HalloweenDefence.js'; //IMPORTANT: Un-comment this line if you have packed all
files into one
d.body.appendChild ( s ) ;
document.ccConfig = c ;
s.id = 'Cocos2d-html5' ;
//else if single file specified, load singlefile
} ) ;
Listing 24-24. Single-File Loading Mode in cocos2d.js
window. addEventListener ( 'DOMContentLoaded' , function ( ) {
//first load engine file if specified
var s = d.createElement ( 'script' ) ;
s.src = 'HalloweenDefence.js' ; //IMPORTANT: Un-comment this line if you have packed all
files into one
d.body.appendChild ( s ) ;
document. ccConfig = c ;
s.id = 'Cocos2d-html5' ;
//else if single file specified, load singlefile
} ) ;
After changing the loading file to HalloweenDefence.js , the game will load this obfuscated file. You also can use
Texture Packer to package all of the game images into sprite sheets, which are supported by Cocos2d-html5 natively.
The last thing you need to do is to deploy the HalloweenDefence folder or full project folder to the web server folder
and visit it via the browsers. Enjoy!
Search WWH ::




Custom Search