drgame-cc 1.0.0 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/drgame-cc.js +143 -0
- package/build-templates/web-mobile/16+.png +0 -0
- package/build-templates/web-mobile/bg1.jpg +0 -0
- package/build-templates/web-mobile/index.html +187 -0
- package/build-templates/web-mobile/jz-jdt-3.png +0 -0
- package/build-templates/web-mobile/jz-jdt-4.png +0 -0
- package/build-templates/web-mobile/logo.png +0 -0
- package/build-templates/web-mobile/main.js +165 -0
- package/build-templates/web-mobile/splash.png +0 -0
- package/build-templates/web-mobile/splash_en.png +0 -0
- package/build-templates/web-mobile/src/hls.min.js +1 -0
- package/build-templates/web-mobile/style-mobile.css +187 -0
- package/dist/asset-exporter.d.ts +9 -0
- package/dist/asset-exporter.d.ts.map +1 -1
- package/dist/asset-exporter.js +69 -0
- package/dist/asset-exporter.js.map +1 -1
- package/dist/asset-types.d.ts +4 -0
- package/dist/asset-types.d.ts.map +1 -1
- package/dist/utils.d.ts +21 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +76 -9
- package/dist/utils.js.map +1 -1
- package/package.json +15 -2
- package/scripts/postinstall.js +152 -0
package/bin/drgame-cc.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* drgame-cc CLI 工具
|
|
5
|
+
* 用于手动触发 build-templates 拷贝
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
// 颜色输出
|
|
12
|
+
const colors = {
|
|
13
|
+
reset: '\x1b[0m',
|
|
14
|
+
green: '\x1b[32m',
|
|
15
|
+
yellow: '\x1b[33m',
|
|
16
|
+
red: '\x1b[31m',
|
|
17
|
+
cyan: '\x1b[36m'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function log(message, color = 'reset') {
|
|
21
|
+
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 递归拷贝目录
|
|
26
|
+
*/
|
|
27
|
+
function copyDir(src, dest) {
|
|
28
|
+
if (!fs.existsSync(src)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!fs.existsSync(dest)) {
|
|
33
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
37
|
+
|
|
38
|
+
for (const entry of entries) {
|
|
39
|
+
const srcPath = path.join(src, entry.name);
|
|
40
|
+
const destPath = path.join(dest, entry.name);
|
|
41
|
+
|
|
42
|
+
if (entry.isDirectory()) {
|
|
43
|
+
copyDir(srcPath, destPath);
|
|
44
|
+
} else {
|
|
45
|
+
fs.copyFileSync(srcPath, destPath);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 查找项目根目录
|
|
54
|
+
*/
|
|
55
|
+
function findProjectRoot(startDir) {
|
|
56
|
+
let currentDir = startDir;
|
|
57
|
+
|
|
58
|
+
while (currentDir !== path.dirname(currentDir)) {
|
|
59
|
+
if (fs.existsSync(path.join(currentDir, 'assets')) ||
|
|
60
|
+
fs.existsSync(path.join(currentDir, 'Assets'))) {
|
|
61
|
+
return currentDir;
|
|
62
|
+
}
|
|
63
|
+
currentDir = path.dirname(currentDir);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 拷贝 build-templates
|
|
71
|
+
*/
|
|
72
|
+
function copyBuildTemplates() {
|
|
73
|
+
log('========================================', 'cyan');
|
|
74
|
+
log('🚀 drgame-cc 拷贝 build-templates', 'cyan');
|
|
75
|
+
log('========================================', 'cyan');
|
|
76
|
+
|
|
77
|
+
const cwd = process.cwd();
|
|
78
|
+
log(`当前目录: ${cwd}`, 'yellow');
|
|
79
|
+
|
|
80
|
+
// 查找项目根目录
|
|
81
|
+
const projectRoot = findProjectRoot(cwd);
|
|
82
|
+
|
|
83
|
+
if (!projectRoot) {
|
|
84
|
+
log('⚠️ 未找到 Cocos Creator 项目根目录', 'yellow');
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
log(`项目根目录: ${projectRoot}`, 'green');
|
|
89
|
+
|
|
90
|
+
// 获取包内的 build-templates 路径
|
|
91
|
+
const packageDir = path.resolve(__dirname, '..');
|
|
92
|
+
const sourceDir = path.join(packageDir, 'build-templates');
|
|
93
|
+
const targetDir = path.join(projectRoot, 'build-templates');
|
|
94
|
+
|
|
95
|
+
log(`源目录: ${sourceDir}`, 'yellow');
|
|
96
|
+
log(`目标目录: ${targetDir}`, 'yellow');
|
|
97
|
+
|
|
98
|
+
// 检查源目录
|
|
99
|
+
if (!fs.existsSync(sourceDir)) {
|
|
100
|
+
log('⚠️ 包内没有 build-templates 目录', 'yellow');
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 检查目标目录
|
|
105
|
+
if (fs.existsSync(targetDir)) {
|
|
106
|
+
log('⚠️ 项目根目录已存在 build-templates,跳过拷贝', 'yellow');
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 执行拷贝
|
|
111
|
+
log('\n📋 开始拷贝...', 'cyan');
|
|
112
|
+
const success = copyDir(sourceDir, targetDir);
|
|
113
|
+
|
|
114
|
+
if (success) {
|
|
115
|
+
log('\n✅ build-templates 拷贝成功!', 'green');
|
|
116
|
+
const items = fs.readdirSync(targetDir);
|
|
117
|
+
log(`📄 包含 ${items.length} 个文件/目录`, 'cyan');
|
|
118
|
+
return true;
|
|
119
|
+
} else {
|
|
120
|
+
log('\n❌ 拷贝失败', 'red');
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// 命令处理
|
|
126
|
+
const args = process.argv.slice(2);
|
|
127
|
+
const command = args[0];
|
|
128
|
+
|
|
129
|
+
switch (command) {
|
|
130
|
+
case 'init':
|
|
131
|
+
case 'copy-templates':
|
|
132
|
+
copyBuildTemplates();
|
|
133
|
+
break;
|
|
134
|
+
case 'help':
|
|
135
|
+
default:
|
|
136
|
+
log('drgame-cc CLI 工具', 'cyan');
|
|
137
|
+
log('', 'reset');
|
|
138
|
+
log('用法:', 'yellow');
|
|
139
|
+
log(' npx drgame-cc init 拷贝 build-templates 到项目根目录', 'reset');
|
|
140
|
+
log(' npx drgame-cc copy-templates 同上', 'reset');
|
|
141
|
+
log(' npx drgame-cc help 显示帮助', 'reset');
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
|
|
7
|
+
<title>互影派</title>
|
|
8
|
+
|
|
9
|
+
<!--http://www.html5rocks.com/en/mobile/mobifying/-->
|
|
10
|
+
<meta name="viewport"
|
|
11
|
+
content="width=device-width,user-scalable=no,initial-scale=1, minimum-scale=1,maximum-scale=1" />
|
|
12
|
+
|
|
13
|
+
<!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
|
|
14
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
15
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
16
|
+
<meta name="format-detection" content="telephone=no">
|
|
17
|
+
<meta name="mobile-web-app-capable" content="yes">
|
|
18
|
+
<!-- force webkit on 360 -->
|
|
19
|
+
<meta name="renderer" content="webkit" />
|
|
20
|
+
<meta name="force-rendering" content="webkit" />
|
|
21
|
+
<!-- force edge on IE -->
|
|
22
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
|
23
|
+
<meta name="msapplication-tap-highlight" content="no">
|
|
24
|
+
|
|
25
|
+
<!-- force full screen on some browser -->
|
|
26
|
+
<meta name="full-screen" content="yes" />
|
|
27
|
+
<meta name="x5-fullscreen" content="true" />
|
|
28
|
+
<meta name="360-fullscreen" content="true" />
|
|
29
|
+
|
|
30
|
+
<!-- force screen orientation on some browser -->
|
|
31
|
+
<meta name="screen-orientation" content="landscape" />
|
|
32
|
+
<meta name="x5-orientation" content="landscape">
|
|
33
|
+
|
|
34
|
+
<!--fix fireball/issues/3568 -->
|
|
35
|
+
<!--<meta name="browsermode" content="application">-->
|
|
36
|
+
<meta name="x5-page-mode" content="app">
|
|
37
|
+
|
|
38
|
+
<!--<link rel="apple-touch-icon" href=".png" />-->
|
|
39
|
+
<!--<link rel="apple-touch-icon-precomposed" href=".png" />-->
|
|
40
|
+
|
|
41
|
+
<link rel="stylesheet" type="text/css" href="style-mobile.css" />
|
|
42
|
+
<link rel="icon" href="favicon.ico" />
|
|
43
|
+
</head>
|
|
44
|
+
|
|
45
|
+
<body>
|
|
46
|
+
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="-1" style="outline: none;"></canvas>
|
|
47
|
+
<div id="splash">
|
|
48
|
+
<!-- <img id="logo" src="logo.png" alt="Logo"> -->
|
|
49
|
+
<div id="splash-info">首次加载时间较长,请耐心等待</div>
|
|
50
|
+
<div id="progress-status">正在启动引擎...0%</div>
|
|
51
|
+
<div class="progress-bar">
|
|
52
|
+
<span style="width: 0%"></span>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div id="icp">备案号:豫ICP备18029698号-5A</div>
|
|
56
|
+
<img id="age-rating" src="16+.png" alt="16+">
|
|
57
|
+
</div>
|
|
58
|
+
<script src="src/settings.js" charset="utf-8"></script>
|
|
59
|
+
<script src="vconsole.min.js"></script>
|
|
60
|
+
<script src="main.js" charset="utf-8"></script>
|
|
61
|
+
|
|
62
|
+
<script type="text/javascript">
|
|
63
|
+
(function () {
|
|
64
|
+
// open web debugger console
|
|
65
|
+
if (typeof VConsole !== 'undefined') {
|
|
66
|
+
window.vConsole = new VConsole();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var debug = window._CCSettings.debug;
|
|
70
|
+
var splash = document.getElementById('splash');
|
|
71
|
+
splash.style.display = 'block';
|
|
72
|
+
|
|
73
|
+
function loadScript(moduleName, cb) {
|
|
74
|
+
function scriptLoaded() {
|
|
75
|
+
document.body.removeChild(domScript);
|
|
76
|
+
domScript.removeEventListener('load', scriptLoaded, false);
|
|
77
|
+
cb && cb();
|
|
78
|
+
};
|
|
79
|
+
var domScript = document.createElement('script');
|
|
80
|
+
domScript.async = true;
|
|
81
|
+
domScript.src = moduleName;
|
|
82
|
+
domScript.addEventListener('load', scriptLoaded, false);
|
|
83
|
+
document.body.appendChild(domScript);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
loadScript(debug ? 'cocos2d-js.js' : 'cocos2d-js-min.js', function () {
|
|
87
|
+
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
|
|
88
|
+
loadScript(debug ? 'physics.js' : 'physics-min.js', window.boot);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
window.boot();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
var progressBar = document.querySelector('.progress-bar');
|
|
96
|
+
var progressSpan = document.querySelector('.progress-bar span');
|
|
97
|
+
var progressText = document.getElementById('progress-status');
|
|
98
|
+
|
|
99
|
+
var observer = new MutationObserver(function (mutations) {
|
|
100
|
+
mutations.forEach(function (mutation) {
|
|
101
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
|
|
102
|
+
var width = progressSpan.style.width;
|
|
103
|
+
var percent = parseFloat(width);
|
|
104
|
+
if (percent <= 90)
|
|
105
|
+
progressText.innerText = "正在启动引擎..." + percent + '%';
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
if (progressSpan) {
|
|
110
|
+
observer.observe(progressSpan, { attributes: true });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
})();
|
|
115
|
+
//桥接webview
|
|
116
|
+
var callbacks = [];
|
|
117
|
+
var isAndroid = navigator.userAgent.indexOf('Android') > -1;
|
|
118
|
+
function setupWebViewJavascriptBridge(callback) {
|
|
119
|
+
if (isAndroid) {
|
|
120
|
+
// 安卓
|
|
121
|
+
if (window.WebViewJavascriptBridge) {
|
|
122
|
+
callback(WebViewJavascriptBridge)
|
|
123
|
+
} else {
|
|
124
|
+
document.addEventListener('WebViewJavascriptBridgeReady', function () {
|
|
125
|
+
callback(WebViewJavascriptBridge)
|
|
126
|
+
}, false)
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
// 苹果
|
|
130
|
+
if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
|
|
131
|
+
if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
|
|
132
|
+
window.WVJBCallbacks = [callback];
|
|
133
|
+
var WVJBIframe = document.createElement('iframe');
|
|
134
|
+
WVJBIframe.style.display = 'none';
|
|
135
|
+
WVJBIframe.src = 'https://__bridge_loaded__';
|
|
136
|
+
document.documentElement.appendChild(WVJBIframe);
|
|
137
|
+
setTimeout(function () { document.documentElement.removeChild(WVJBIframe) }, 0);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
setupWebViewJavascriptBridge(function (bridge) {
|
|
142
|
+
if (isAndroid) {
|
|
143
|
+
bridge.init();
|
|
144
|
+
}
|
|
145
|
+
bridge.registerHandler('app2Web', function (data, responseCallback) {
|
|
146
|
+
registerHandler(data, responseCallback);
|
|
147
|
+
});
|
|
148
|
+
prompt('//', 'bridge/ready');
|
|
149
|
+
window.bridge = bridge;
|
|
150
|
+
for (const callback of callbacks) {
|
|
151
|
+
callback();
|
|
152
|
+
}
|
|
153
|
+
callbacks = [];
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
function callHandler(api, params, callback) {
|
|
158
|
+
//console.log(api,params);
|
|
159
|
+
var tempCallback = function () {
|
|
160
|
+
bridge.callHandler('web2App', { 'api': api, 'params': params }, function (response) {
|
|
161
|
+
callback(response);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (window.bridge) {
|
|
165
|
+
tempCallback();
|
|
166
|
+
} else {
|
|
167
|
+
callbacks.push(tempCallback);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// app2Web 异步函数
|
|
172
|
+
function registerHandler(data, responseCallback) {
|
|
173
|
+
console.log('registerHandler ' + data.api + " , " + data.res);
|
|
174
|
+
/*
|
|
175
|
+
// (示例)app调用web部分:
|
|
176
|
+
if (data.api === 'pay/requestApplePurchase') {
|
|
177
|
+
console.log('JS got request ', data);
|
|
178
|
+
}
|
|
179
|
+
*/
|
|
180
|
+
window.postMessage(data, '*'); // 注意目标源安全性
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
</script>
|
|
184
|
+
|
|
185
|
+
</body>
|
|
186
|
+
|
|
187
|
+
</html>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
window.boot = function () {
|
|
2
|
+
var settings = window._CCSettings;
|
|
3
|
+
window._CCSettings = undefined;
|
|
4
|
+
var onProgress = null;
|
|
5
|
+
|
|
6
|
+
var RESOURCES = cc.AssetManager.BuiltinBundleName.RESOURCES;
|
|
7
|
+
var INTERNAL = cc.AssetManager.BuiltinBundleName.INTERNAL;
|
|
8
|
+
var MAIN = cc.AssetManager.BuiltinBundleName.MAIN;
|
|
9
|
+
function setLoadingDisplay () {
|
|
10
|
+
// Loading splash scene
|
|
11
|
+
var splash = document.getElementById('splash');
|
|
12
|
+
var progressBar = splash.querySelector('.progress-bar span');
|
|
13
|
+
var progressStatus = document.getElementById('progress-status');
|
|
14
|
+
onProgress = function (finish, total) {
|
|
15
|
+
var percent = 100 * finish / total;
|
|
16
|
+
if (progressBar) {
|
|
17
|
+
progressBar.style.width = percent.toFixed(2) + '%';
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
splash.style.display = 'block';
|
|
21
|
+
// Lock displayed progress to 90% so the splash won't auto-complete.
|
|
22
|
+
onProgress = function (finish, total) {
|
|
23
|
+
var percent = 100 * finish / total;
|
|
24
|
+
var displayPercent = Math.min(Math.max(percent, 0), 100);
|
|
25
|
+
displayPercent = Math.min(displayPercent, 90);
|
|
26
|
+
if (progressBar) {
|
|
27
|
+
progressBar.style.width = displayPercent.toFixed(2) + '%';
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
window.setProgress = function (v,vv=undefined) {
|
|
31
|
+
if (progressBar) {
|
|
32
|
+
progressBar.style.width = v + '%';
|
|
33
|
+
}
|
|
34
|
+
if(vv!==undefined){
|
|
35
|
+
progressStatus.innerText = vv+v+'%';
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Prevent automatic hiding. Provide a manual API to close the loading splash.
|
|
40
|
+
window.closeLoading = function () {
|
|
41
|
+
if (splash) splash.style.display = 'none';
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var onStart = function () {
|
|
46
|
+
|
|
47
|
+
cc.view.enableRetina(true);
|
|
48
|
+
cc.view.resizeWithBrowserSize(true);
|
|
49
|
+
|
|
50
|
+
if (cc.sys.isBrowser) {
|
|
51
|
+
setLoadingDisplay();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (cc.sys.isMobile) {
|
|
55
|
+
if (settings.orientation === 'landscape') {
|
|
56
|
+
cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
|
|
57
|
+
}
|
|
58
|
+
else if (settings.orientation === 'portrait') {
|
|
59
|
+
cc.view.setOrientation(cc.macro.ORIENTATION_PORTRAIT);
|
|
60
|
+
}
|
|
61
|
+
cc.view.enableAutoFullScreen([
|
|
62
|
+
cc.sys.BROWSER_TYPE_BAIDU,
|
|
63
|
+
cc.sys.BROWSER_TYPE_BAIDU_APP,
|
|
64
|
+
cc.sys.BROWSER_TYPE_WECHAT,
|
|
65
|
+
cc.sys.BROWSER_TYPE_MOBILE_QQ,
|
|
66
|
+
cc.sys.BROWSER_TYPE_MIUI,
|
|
67
|
+
cc.sys.BROWSER_TYPE_HUAWEI,
|
|
68
|
+
cc.sys.BROWSER_TYPE_UC,
|
|
69
|
+
].indexOf(cc.sys.browserType) < 0&&false);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Limit downloading max concurrent task to 2,
|
|
73
|
+
// more tasks simultaneously may cause performance draw back on some android system / browsers.
|
|
74
|
+
// You can adjust the number based on your own test result, you have to set it before any loading process to take effect.
|
|
75
|
+
if (cc.sys.isBrowser && cc.sys.os === cc.sys.OS_ANDROID) {
|
|
76
|
+
cc.assetManager.downloader.maxConcurrency = 2;
|
|
77
|
+
cc.assetManager.downloader.maxRequestsPerFrame = 2;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var launchScene = settings.launchScene;
|
|
81
|
+
var bundle = cc.assetManager.bundles.find(function (b) {
|
|
82
|
+
return b.getSceneInfo(launchScene);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
bundle.loadScene(launchScene, null, onProgress,
|
|
86
|
+
function (err, scene) {
|
|
87
|
+
if (!err) {
|
|
88
|
+
cc.director.runSceneImmediate(scene);
|
|
89
|
+
if (cc.sys.isBrowser) {
|
|
90
|
+
// show canvas
|
|
91
|
+
var canvas = document.getElementById('GameCanvas');
|
|
92
|
+
canvas.style.visibility = '';
|
|
93
|
+
var div = document.getElementById('GameDiv');
|
|
94
|
+
if (div) {
|
|
95
|
+
div.style.backgroundImage = '';
|
|
96
|
+
}
|
|
97
|
+
console.log('Success to load scene: ' + launchScene);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
var option = {
|
|
106
|
+
id: 'GameCanvas',
|
|
107
|
+
debugMode: settings.debug ? cc.debug.DebugMode.INFO : cc.debug.DebugMode.ERROR,
|
|
108
|
+
showFPS: settings.debug,
|
|
109
|
+
frameRate: 60,
|
|
110
|
+
groupList: settings.groupList,
|
|
111
|
+
collisionMatrix: settings.collisionMatrix,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
cc.assetManager.init({
|
|
115
|
+
bundleVers: settings.bundleVers,
|
|
116
|
+
remoteBundles: settings.remoteBundles,
|
|
117
|
+
server: settings.server
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
var bundleRoot = [INTERNAL];
|
|
121
|
+
settings.hasResourcesBundle && bundleRoot.push(RESOURCES);
|
|
122
|
+
|
|
123
|
+
var count = 0;
|
|
124
|
+
function cb (err) {
|
|
125
|
+
if (err) return console.error(err.message, err.stack);
|
|
126
|
+
count++;
|
|
127
|
+
if (count === bundleRoot.length + 1) {
|
|
128
|
+
cc.assetManager.loadBundle(MAIN, function (err) {
|
|
129
|
+
if (!err) {
|
|
130
|
+
cc.macro.ENABLE_TRANSPARENT_CANVAS = true;
|
|
131
|
+
cc.game.run(option, onStart);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
cc.assetManager.loadScript(settings.jsList.map(function (x) { return 'src/' + x;}), cb);
|
|
138
|
+
|
|
139
|
+
for (var i = 0; i < bundleRoot.length; i++) {
|
|
140
|
+
cc.assetManager.loadBundle(bundleRoot[i], cb);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
if (window.jsb) {
|
|
145
|
+
var isRuntime = (typeof loadRuntime === 'function');
|
|
146
|
+
if (isRuntime) {
|
|
147
|
+
require('src/settings.js');
|
|
148
|
+
require('src/cocos2d-runtime.js');
|
|
149
|
+
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
|
|
150
|
+
require('src/physics.js');
|
|
151
|
+
}
|
|
152
|
+
require('jsb-adapter/engine/index.js');
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
require('src/settings.js');
|
|
156
|
+
require('src/cocos2d-jsb.js');
|
|
157
|
+
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
|
|
158
|
+
require('src/physics.js');
|
|
159
|
+
}
|
|
160
|
+
require('jsb-adapter/jsb-engine.js');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
cc.macro.CLEANUP_IMAGE_CACHE = true;
|
|
164
|
+
window.boot();
|
|
165
|
+
}
|
|
Binary file
|
|
Binary file
|