This repository was archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcocos2d.js
executable file
·80 lines (75 loc) · 2.73 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
(function() {
var d = document;
var c = {
box2d: false,
chipmunk: false,
showFPS: window.location.protocol == "file:",
loadExtension: false,
frameRate: 60,
renderMode: 0, //Choose of RenderMode: 0(default), 1(Canvas only), 2(WebGL only)
tag: 'game', //the dom element to run cocos2d on
//engineDir: 'cocos2d/',
SingleEngineFile: 'cocos2d.min.js',
appFiles:[
'src/GameScene.js',
'src/KeyboardControlLayer.js',
'src/WorldObjectNode.js',
'src/ObstacleNode.js',
'src/SnakeNode.js',
'src/SnakeBitsNode.js',
'src/PowerupNode.js',
'src/SpawnNode.js',
'src/PerkBar.js',
'src/GameNodeFactory.js',
'src/GameLayer.js',
'src/WaitLoad.js',
'src/Scoreboard.js',
],
resourceFiles: [
{src: 'res/snake-1.png'},
{src: 'res/snake-2.png'},
{src: 'res/snake-3.png'},
{src: 'res/snake-4.png'},
{src: 'res/snake-5.png'},
{src: 'res/snake-6.png'},
{src: 'res/food.png'},
{src: 'res/tiles.png'},
{src: 'res/forest.jpg'},
{src: 'res/halo.png'},
{src: 'res/down.png'},
{src: 'res/powerup.png'},
{src: 'res/buff.png'},
]
};
if ( !d.createElement( 'canvas' ).getContext ) {
var s = d.createElement( 'div' );
s.innerHTML = '<h2>Your browser does not support HTML5 canvas!</h2>' +
'<p>Google Chrome is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier.Click the logo to download.</p>' +
'<a href="http://www.google.com/chrome" target="_blank"><img src="http://www.google.com/intl/zh-CN/chrome/assets/common/images/chrome_logo_2x.png" border="0"/></a>';
var p = d.getElementById( c.tag ).parentNode;
p.style.background = 'none';
p.style.border = 'none';
p.insertBefore( s, d.getElementById( c.tag ) );
d.body.style.background = '#ffffff';
return;
}
window.addEventListener( 'DOMContentLoaded', function() {
this.removeEventListener( 'DOMContentLoaded', arguments.callee, false );
//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 + '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 = 'myTemplate.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
});
})();