修改加载进程

This commit is contained in:
unanmed 2023-02-28 19:39:34 +08:00
parent c7168ccfde
commit c4e0b706f9
5 changed files with 179 additions and 304 deletions

View File

@ -286,7 +286,6 @@ core.prototype.init = function (coreData, callback) {
this._init_flags(); this._init_flags();
this._init_platform(); this._init_platform();
this._init_others(); this._init_others();
this._init_plugins();
var b = main.mode == 'editor'; var b = main.mode == 'editor';
// 初始化画布 // 初始化画布
for (var name in core.canvas) { for (var name in core.canvas) {
@ -589,51 +588,6 @@ core.prototype._afterLoadResources = function (callback) {
if (callback) callback(); if (callback) callback();
}; };
core.prototype._init_plugins = function () {
core.plugin = new (function () {})();
for (var name in plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1) {
if (
plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1[name] instanceof
Function
) {
try {
plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1[name].apply(
core.plugin
);
} catch (e) {
console.error(e);
console.error('无法初始化插件' + name);
}
}
}
if (!main.pluginUseCompress) {
(async function () {
const pluginList = main.plugin;
for await (const one of pluginList) {
const script = document.createElement('script');
script.src = `project/plugin/${one}.js`;
document.body.appendChild(script);
await new Promise(res => {
script.addEventListener('load', res);
});
}
})();
} else {
const script = document.createElement('script');
script.src = `project/plugin.min.js`;
document.body.appendChild(script);
}
core._forwardFunc('plugin');
if (!main.replayChecking && main.mode === 'play') {
main.forward();
core.resetSettings();
core.plugin.showMarkedEnemy.value = true;
}
};
core.prototype._forwardFuncs = function () { core.prototype._forwardFuncs = function () {
for (var i = 0; i < main.loadList.length; ++i) { for (var i = 0; i < main.loadList.length; ++i) {
var name = main.loadList[i]; var name = main.loadList[i];

View File

@ -1,7 +1,8 @@
///<reference path="../src/types/core.d.ts" />
function main() { function main() {
//------------------------ 用户修改内容 ------------------------// //------------------------ 用户修改内容 ------------------------//
this.version = '2.10.0'; // 游戏版本号如果更改了游戏内容建议修改此version以免造成缓存问题。 this.version = '1.0.0'; // 游戏版本号如果更改了游戏内容建议修改此version以免造成缓存问题。
this.useCompress = false; // 是否使用压缩文件 this.useCompress = false; // 是否使用压缩文件
this.pluginUseCompress = false; // 仅限于gh-pages使用 this.pluginUseCompress = false; // 仅限于gh-pages使用
@ -218,15 +219,23 @@ function main() {
} }
// >>>> body end // >>>> body end
main.prototype.init = function (mode, callback) { main.prototype.loadScript = async function (src) {
const script = document.createElement('script');
script.src = src;
document.body.appendChild(script);
await new Promise(res => {
script.addEventListener('load', res);
});
};
main.prototype.init = async function (mode, callback) {
try { try {
var a = {}; var a = {};
var b = {}; var b = {};
new Proxy(a, b); new Proxy(a, b);
new Promise(res => res()); new Promise(res => res());
const aa = `${123}`; eval('`${123}`');
aa; } catch {
} catch (e) {
alert('浏览器版本过低,无法游玩本塔!'); alert('浏览器版本过低,无法游玩本塔!');
return; return;
} }
@ -237,25 +246,62 @@ main.prototype.init = function (mode, callback) {
} }
main.mode = mode; main.mode = mode;
Promise.all(); // 加载全塔属性代码
if (main.useCompress) {
main.loadJs('project', main.pureData, function () { await main.loadScript(`project/project.min.js?v=${main.version}`);
var mainData = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main; } else {
for (var ii in mainData) main[ii] = mainData[ii]; await Promise.all(
main.pureData.map(v =>
main.loadScript(`project/${v}.js?v=${main.version}`)
)
);
}
const mainData = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main;
Object.assign(main, mainData);
main.importFonts(main.fonts); main.importFonts(main.fonts);
main.loadJs('libs', main.loadList, function () { // 加载核心js代码
main.core = core; if (main.useCompress) {
await main.loadScript(`libs/libs.min.js?v=${main.version}`);
for (i = 0; i < main.loadList.length; i++) { } else {
var name = main.loadList[i]; await Promise.all(
if (name === 'core') continue; main.loadList.map(v =>
main.core[name] = new window[name](); main.loadScript(`libs/${v}.js?v=${main.version}`)
)
);
} }
main.loadFloors(function () { for (const name of main.loadList) {
var coreData = {}; if (name === 'core') continue;
core[name] = new window[name]();
}
// 加载楼层
main.setMainTipsText('正在加载楼层文件...');
if (main.useCompress) {
await main.loadScript(`project/floors.min.js?v=${main.version}`);
main.dom.mainTips.style.display = 'none';
} else {
try {
await main.loadScript(
`/all/__all_floors__.js?v=${
main.version
}&id=${main.floorIds.join(',')}`
);
main.dom.mainTips.style.display = 'none';
main.supportBunch = true;
} catch {
await Promise.all(
mainData.floorIds.map(v =>
main.loadScript(`project/floors/${v}.js`)
)
);
}
}
// 初始化core
const coreData = {};
[ [
'dom', 'dom',
'statusBar', 'statusBar',
@ -274,29 +320,39 @@ main.prototype.init = function (mode, callback) {
}); });
core.init(coreData, callback); core.init(coreData, callback);
core.resize(); core.resize();
core.plugin = {};
// 加载插件
if (!main.replayChecking && main.mode === 'play') {
main.forward();
core.resetSettings();
core.plugin.showMarkedEnemy.value = true;
}
if (main.useCompress) {
await main.loadScript(`project/plugin.min.js?v=${main.version}`);
} else {
for await (const plugin of mainData.plugin) {
await main.loadScript(
`project/plugin/${plugin}.js?v=${main.version}`
);
}
}
// 自动放缩最大化 // 自动放缩最大化
if (core.getLocalStorage('autoScale') == null) { const auto = core.getLocalStorage('autoScale');
if (auto == null) {
core.setLocalStorage('autoScale', true); core.setLocalStorage('autoScale', true);
} }
if ( if (auto && !core.domStyle.isVertical) {
core.getLocalStorage('autoScale') &&
!core.domStyle.isVertical
) {
try { try {
if (core) { core.plugin.utils.maxGameScale();
core.plugin.maxGameScale();
if (!core.getLocalStorage('fullscreen', false)) { if (!core.getLocalStorage('fullscreen', false)) {
requestAnimationFrame(function () { requestAnimationFrame(() => {
var style = getComputedStyle( var style = getComputedStyle(main.dom.gameGroup);
main.dom.gameGroup
);
var height = parseFloat(style.height); var height = parseFloat(style.height);
if (height > window.innerHeight * 0.95) { if (height > window.innerHeight * 0.95) {
core.control.setDisplayScale(-1); core.control.setDisplayScale(-1);
if ( if (!core.isPlaying() && core.flags.enableHDCanvas) {
!core.isPlaying() &&
core.flags.enableHDCanvas
) {
core.domStyle.ratio = Math.max( core.domStyle.ratio = Math.max(
window.devicePixelRatio || 1, window.devicePixelRatio || 1,
core.domStyle.scale core.domStyle.scale
@ -306,115 +362,8 @@ main.prototype.init = function (mode, callback) {
} }
}); });
} }
} catch {}
} }
} catch (e) {
console.error(e);
}
}
});
});
});
};
////// 动态加载所有核心JS文件 //////
main.prototype.loadJs = function (dir, loadList, callback) {
// 加载js
main.setMainTipsText('正在加载核心js文件...');
if (this.useCompress) {
main.loadMod(dir, dir, function () {
callback();
});
} else {
var instanceNum = 0;
for (var i = 0; i < loadList.length; i++) {
main.loadMod(dir, loadList[i], function (modName) {
main.setMainTipsText(modName + '.js 加载完毕');
instanceNum++;
if (instanceNum === loadList.length) {
callback();
}
});
}
}
};
////// 加载某一个JS文件 //////
main.prototype.loadMod = function (dir, modName, callback, onerror) {
var script = document.createElement('script');
var name = modName;
script.src =
dir +
'/' +
modName +
(this.useCompress ? '.min' : '') +
'.js?v=' +
this.version;
script.onload = function () {
callback(name);
};
main.dom.body.appendChild(script);
};
////// 动态加载所有楼层(剧本) //////
main.prototype.loadFloors = function (callback) {
// 加载js
main.setMainTipsText('正在加载楼层文件...');
if (this.useCompress) {
// 读取压缩文件
var script = document.createElement('script');
script.src = 'project/floors.min.js?v=' + this.version;
main.dom.body.appendChild(script);
script.onload = function () {
main.dom.mainTips.style.display = 'none';
callback();
};
return;
}
// 高层塔优化
var script = document.createElement('script');
script.src =
'/all/__all_floors__.js?v=' +
this.version +
'&id=' +
main.floorIds.join(',');
script.onload = function () {
main.dom.mainTips.style.display = 'none';
main.supportBunch = true;
callback();
};
script.onerror =
script.onabort =
script.ontimeout =
function (e) {
// console.clear();
for (var i = 0; i < main.floorIds.length; i++) {
main.loadFloor(main.floorIds[i], function (modName) {
main.setMainTipsText(
'楼层 ' + modName + '.js 加载完毕'
);
if (
Object.keys(main.floors).length ===
main.floorIds.length
) {
main.dom.mainTips.style.display = 'none';
callback();
}
});
}
};
main.dom.body.appendChild(script);
};
////// 加载某一个楼层 //////
main.prototype.loadFloor = function (floorId, callback) {
var script = document.createElement('script');
script.src = 'project/floors/' + floorId + '.js?v=' + this.version;
main.dom.body.appendChild(script);
script.onload = function () {
callback(floorId);
};
}; };
////// 加载过程提示 ////// ////// 加载过程提示 //////
@ -422,17 +371,6 @@ main.prototype.setMainTipsText = function (text) {
main.dom.mainTips.innerHTML = text; main.dom.mainTips.innerHTML = text;
}; };
main.prototype.log = function (e, error) {
if (e) {
if (error) return console.error(e);
if (main.core && main.core.platform && !main.core.platform.isPC) {
console.log(e.stack || e.toString());
} else {
console.log(e);
}
}
};
main.prototype.createOnChoiceAnimation = function () { main.prototype.createOnChoiceAnimation = function () {
var borderColor = var borderColor =
main.dom.startButtonGroup.style.caretColor || 'rgb(255, 215, 0)'; main.dom.startButtonGroup.style.caretColor || 'rgb(255, 215, 0)';
@ -485,7 +423,7 @@ main.prototype.listen = function () {
////// 窗口大小变化时 ////// ////// 窗口大小变化时 //////
window.onresize = function () { window.onresize = function () {
try { try {
main.core.resize(); core.resize();
} catch (ee) { } catch (ee) {
console.error(ee); console.error(ee);
} }
@ -497,11 +435,8 @@ main.prototype.listen = function () {
try { try {
if (e.keyCode === 27) e.preventDefault(); if (e.keyCode === 27) e.preventDefault();
if (main.dom.inputDiv.style.display == 'block') return; if (main.dom.inputDiv.style.display == 'block') return;
if ( if (core && (core.isPlaying() || core.status.lockControl))
main.core && core.onkeyDown(e);
(main.core.isPlaying() || main.core.status.lockControl)
)
main.core.onkeyDown(e);
} catch (ee) { } catch (ee) {
console.error(ee); console.error(ee);
} }
@ -530,7 +465,7 @@ main.prototype.listen = function () {
main.dom.levelChooseButtons.style.display == 'block' main.dom.levelChooseButtons.style.display == 'block'
) { ) {
// ESC // ESC
main.core.showStartAnimate(true); core.showStartAnimate(true);
e.preventDefault(); e.preventDefault();
} }
e.stopPropagation(); e.stopPropagation();
@ -549,12 +484,12 @@ main.prototype.listen = function () {
return; return;
} }
if ( if (
main.core && core &&
main.core.isPlaying && core.isPlaying &&
main.core.status && core.status &&
(main.core.isPlaying() || main.core.status.lockControl) (core.isPlaying() || core.status.lockControl)
) )
main.core.onkeyUp(e); core.onkeyUp(e);
} catch (ee) { } catch (ee) {
console.error(ee); console.error(ee);
} }
@ -569,9 +504,9 @@ main.prototype.listen = function () {
main.dom.data.onmousedown = function (e) { main.dom.data.onmousedown = function (e) {
try { try {
e.stopPropagation(); e.stopPropagation();
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); var loc = core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.ondown(loc); core.ondown(loc);
} catch (ee) { } catch (ee) {
console.error(ee); console.error(ee);
} }
@ -580,9 +515,9 @@ main.prototype.listen = function () {
////// 鼠标移动时 ////// ////// 鼠标移动时 //////
main.dom.data.onmousemove = function (e) { main.dom.data.onmousemove = function (e) {
try { try {
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); var loc = core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.onmove(loc); core.onmove(loc);
} catch (ee) { } catch (ee) {
console.error(ee); console.error(ee);
} }
@ -591,9 +526,9 @@ main.prototype.listen = function () {
////// 鼠标放开时 ////// ////// 鼠标放开时 //////
main.dom.data.onmouseup = function (e) { main.dom.data.onmouseup = function (e) {
try { try {
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); var loc = core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.onup(loc); core.onup(loc);
} catch (ee) { } catch (ee) {
console.error(ee); console.error(ee);
} }
@ -602,8 +537,8 @@ main.prototype.listen = function () {
////// 鼠标滑轮滚动时 ////// ////// 鼠标滑轮滚动时 //////
main.dom.data.onmousewheel = function (e) { main.dom.data.onmousewheel = function (e) {
try { try {
if (e.wheelDelta) main.core.onmousewheel(Math.sign(e.wheelDelta)); if (e.wheelDelta) core.onmousewheel(Math.sign(e.wheelDelta));
else if (e.detail) main.core.onmousewheel(Math.sign(e.detail)); else if (e.detail) core.onmousewheel(Math.sign(e.detail));
} catch (ee) { } catch (ee) {
console.error(ee); console.error(ee);
} }
@ -613,13 +548,13 @@ main.prototype.listen = function () {
main.dom.data.ontouchstart = function (e) { main.dom.data.ontouchstart = function (e) {
try { try {
e.preventDefault(); e.preventDefault();
var loc = main.core.actions._getClickLoc( var loc = core.actions._getClickLoc(
e.targetTouches[0].clientX, e.targetTouches[0].clientX,
e.targetTouches[0].clientY e.targetTouches[0].clientY
); );
if (loc == null) return; if (loc == null) return;
main.lastTouchLoc = loc; main.lastTouchLoc = loc;
main.core.ondown(loc); core.ondown(loc);
} catch (ee) { } catch (ee) {
console.error(ee); console.error(ee);
} }
@ -629,13 +564,13 @@ main.prototype.listen = function () {
main.dom.data.ontouchmove = function (e) { main.dom.data.ontouchmove = function (e) {
try { try {
e.preventDefault(); e.preventDefault();
var loc = main.core.actions._getClickLoc( var loc = core.actions._getClickLoc(
e.targetTouches[0].clientX, e.targetTouches[0].clientX,
e.targetTouches[0].clientY e.targetTouches[0].clientY
); );
if (loc == null) return; if (loc == null) return;
main.lastTouchLoc = loc; main.lastTouchLoc = loc;
main.core.onmove(loc); core.onmove(loc);
} catch (ee) { } catch (ee) {
console.error(ee); console.error(ee);
} }
@ -648,7 +583,7 @@ main.prototype.listen = function () {
if (main.lastTouchLoc == null) return; if (main.lastTouchLoc == null) return;
var loc = main.lastTouchLoc; var loc = main.lastTouchLoc;
delete main.lastTouchLoc; delete main.lastTouchLoc;
main.core.onup(loc); core.onup(loc);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
@ -663,7 +598,7 @@ main.prototype.listen = function () {
return; return;
} }
if (main.core.isPlaying()) main.core.openBook(true); if (core.isPlaying()) core.openBook(true);
}; };
////// 点击状态栏中的楼层传送器/装备栏时 ////// ////// 点击状态栏中的楼层传送器/装备栏时 //////
@ -676,11 +611,11 @@ main.prototype.listen = function () {
return; return;
} }
if (main.core.isPlaying()) { if (core.isPlaying()) {
if (!main.core.flags.equipboxButton) { if (!core.flags.equipboxButton) {
main.core.useFly(true); core.useFly(true);
} else { } else {
main.core.openEquipbox(true); core.openEquipbox(true);
} }
} }
}; };
@ -694,8 +629,8 @@ main.prototype.listen = function () {
return; return;
} }
if (main.core.isPlaying()) { if (core.isPlaying()) {
main.core.openToolbox(core.status.event.id != 'equipbox'); core.openToolbox(core.status.event.id != 'equipbox');
} }
}; };
@ -707,7 +642,7 @@ main.prototype.listen = function () {
return; return;
} }
if (main.core.isPlaying()) main.core.openEquipbox(true); if (core.isPlaying()) core.openEquipbox(true);
}; };
////// 点击状态栏中的虚拟键盘时 ////// ////// 点击状态栏中的虚拟键盘时 //////
@ -719,7 +654,7 @@ main.prototype.listen = function () {
return; return;
} }
if (main.core.isPlaying()) main.core.openKeyBoard(true); if (core.isPlaying()) core.openKeyBoard(true);
}; };
////// 点击状态栏中的快捷商店时 ////// ////// 点击状态栏中的快捷商店时 //////
@ -731,14 +666,14 @@ main.prototype.listen = function () {
return; return;
} }
if (main.core.isPlaying()) main.core.openQuickShop(true); if (core.isPlaying()) core.openQuickShop(true);
}; };
////// 点击金币时也可以开启快捷商店 ////// ////// 点击金币时也可以开启快捷商店 //////
main.statusBar.image.money.onclick = function (e) { main.statusBar.image.money.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (main.core.isPlaying()) main.core.openQuickShop(true); if (core.isPlaying()) core.openQuickShop(true);
}; };
////// 点击楼梯图标也可以浏览地图 ////// ////// 点击楼梯图标也可以浏览地图 //////
@ -746,8 +681,8 @@ main.prototype.listen = function () {
e.stopPropagation(); e.stopPropagation();
if ( if (
main.core && core &&
main.core.isPlaying() && core.isPlaying() &&
!core.isMoving() && !core.isMoving() &&
!core.status.lockControl !core.status.lockControl
) { ) {
@ -764,7 +699,7 @@ main.prototype.listen = function () {
return; return;
} }
if (main.core.isPlaying()) main.core.save(true); if (core.isPlaying()) core.save(true);
}; };
////// 点击状态栏中的读档按钮时 ////// ////// 点击状态栏中的读档按钮时 //////
@ -776,7 +711,7 @@ main.prototype.listen = function () {
return; return;
} }
if (main.core.isPlaying()) main.core.load(true); if (core.isPlaying()) core.load(true);
}; };
////// 点击状态栏中的系统菜单时 ////// ////// 点击状态栏中的系统菜单时 //////
@ -788,18 +723,18 @@ main.prototype.listen = function () {
return; return;
} }
if (main.core.isPlaying()) main.core.openSettings(true); if (core.isPlaying()) core.openSettings(true);
}; };
////// 点击工具栏时 ////// ////// 点击工具栏时 //////
main.dom.hard.onclick = function () { main.dom.hard.onclick = function () {
main.core.control.setToolbarButton(!core.domStyle.toolbarBtn); core.control.setToolbarButton(!core.domStyle.toolbarBtn);
}; };
////// 手机端的按钮1-7 ////// ////// 手机端的按钮1-7 //////
main.statusBar.image.btn1.onclick = function (e) { main.statusBar.image.btn1.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({ core.onkeyUp({
keyCode: 49, keyCode: 49,
altKey: core.getLocalStorage('altKey') altKey: core.getLocalStorage('altKey')
}); });
@ -807,7 +742,7 @@ main.prototype.listen = function () {
main.statusBar.image.btn2.onclick = function (e) { main.statusBar.image.btn2.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({ core.onkeyUp({
keyCode: 50, keyCode: 50,
altKey: core.getLocalStorage('altKey') altKey: core.getLocalStorage('altKey')
}); });
@ -815,7 +750,7 @@ main.prototype.listen = function () {
main.statusBar.image.btn3.onclick = function (e) { main.statusBar.image.btn3.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({ core.onkeyUp({
keyCode: 51, keyCode: 51,
altKey: core.getLocalStorage('altKey') altKey: core.getLocalStorage('altKey')
}); });
@ -823,7 +758,7 @@ main.prototype.listen = function () {
main.statusBar.image.btn4.onclick = function (e) { main.statusBar.image.btn4.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({ core.onkeyUp({
keyCode: 52, keyCode: 52,
altKey: core.getLocalStorage('altKey') altKey: core.getLocalStorage('altKey')
}); });
@ -831,7 +766,7 @@ main.prototype.listen = function () {
main.statusBar.image.btn5.onclick = function (e) { main.statusBar.image.btn5.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({ core.onkeyUp({
keyCode: 53, keyCode: 53,
altKey: core.getLocalStorage('altKey') altKey: core.getLocalStorage('altKey')
}); });
@ -839,7 +774,7 @@ main.prototype.listen = function () {
main.statusBar.image.btn6.onclick = function (e) { main.statusBar.image.btn6.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({ core.onkeyUp({
keyCode: 54, keyCode: 54,
altKey: core.getLocalStorage('altKey') altKey: core.getLocalStorage('altKey')
}); });
@ -847,7 +782,7 @@ main.prototype.listen = function () {
main.statusBar.image.btn7.onclick = function (e) { main.statusBar.image.btn7.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({ core.onkeyUp({
keyCode: 55, keyCode: 55,
altKey: core.getLocalStorage('altKey') altKey: core.getLocalStorage('altKey')
}); });
@ -867,9 +802,9 @@ main.prototype.listen = function () {
}; };
window.onblur = function () { window.onblur = function () {
if (main.core && main.core.control) { if (core && core.control) {
try { try {
main.core.control.checkAutosave(); core.control.checkAutosave();
} catch (e) {} } catch (e) {}
} }
}; };

View File

@ -1958,7 +1958,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
try { try {
eval(core.floors[core.status.floorId].parallelDo); eval(core.floors[core.status.floorId].parallelDo);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
} }
} }
} }

View File

@ -1,28 +1,8 @@
///<reference path="../../src/types/core.d.ts" />
var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = {
init: function () { init: function () {
// 这看不到插件插件全放到plugin文件夹里面了要看的话去 关于游戏 的开源地址里面看 // 这看不到插件插件全放到plugin文件夹里面了要看的话去 关于游戏 的开源地址里面看
// 直接把仓库clone下来或者下载zip都行 // 直接把仓库clone下来或者下载zip都行
// 脚本编辑同理 // 脚本编辑同理
this._afterLoadResources = function () {}; this._afterLoadResources = function () {};
},
pluginUtils: function () {
// 保留这个函数以保证main.js能够使用
this.maxGameScale = function (n = 0) {
const index = core.domStyle.availableScale.indexOf(
core.domStyle.scale
);
core.control.setDisplayScale(
core.domStyle.availableScale.length - 1 - index - n
);
if (!core.isPlaying() && core.flags.enableHDCanvas) {
core.domStyle.ratio = Math.max(
window.devicePixelRatio || 1,
core.domStyle.scale
);
core.resize();
}
};
} }
}; };

6
src/types/core.d.ts vendored
View File

@ -1263,6 +1263,12 @@ interface Main extends MainData {
*/ */
init(mode: 'play' | 'editor', callback?: () => void): void; init(mode: 'play' | 'editor', callback?: () => void): void;
/**
*
* @param src
*/
loadScript(src: string): Promise<void>;
/** /**
* js文件 * js文件
* @param dir js文件的目录 * @param dir js文件的目录