fix starting animates

remove animates and bgms
This commit is contained in:
bdf1 2022-11-04 04:17:58 +13:00
parent 2ce883886c
commit f8308d9b7f
5 changed files with 380 additions and 312 deletions

6
.gitignore vendored
View File

@ -1 +1,5 @@
_saves/
_saves/
project/bgms/
project/animates/
_docs/
常用工具/

View File

@ -1 +1 @@
{"viewportLoc":[0,0],"editorLastFloorId":"MT1"}
{"viewportLoc":[0,0],"editorLastFloorId":"QISHI"}

View File

@ -668,7 +668,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"startVerticalBackground": "project/images/bg.jpg",
"startLogoStyle": "display:none",
"startButtonsStyle": "background-color: #32369F; opacity: 0.85; color: #FFFFFF; border: #FFFFFF 2px solid; caret-color: #FFD700;",
"statusLeftBackground": "url(project/images/heng.png) 0 0/100% 100% no-repeat",
"statusLeftBackground": "url(project/images/black.png) 0 0/100% 100% no-repeat",
"statusTopBackground": "url(project/images/shu.png) 0 0/100% 100% no-repeat",
"toolsBackground": "url(project/images/dibu.png) 0 0/100% 100% no-repeat",
"floorChangingStyle": "background-color: black; color: white",
@ -734,7 +734,9 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"x": -1,
"y": 0
},
"flags": {},
"flags": {
"hideStatusBar": true
},
"followers": [],
"steps": 0
},

View File

@ -1594,9 +1594,10 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
.sort( /*function (id1, id2) { return core.material.items[id1].name <= core.material.items[id2].name ? -1 : 1 }*/);
},
"drawStatusBar": function () {
core.dom.caidan1Ctx.drawImage(core.material.images.images['caidan.png'],0,0)
if (!core.status.floorId) return;
if (core.status.floorId == 'nandu') core.clearMap('caidan');
else core.drawImage('caidan','caidan.png',-161,0);
core.dom.caidan1Ctx.drawImage(core.material.images.images['caidan.png'],0,0)
var ctx, fill = function (text, x, y, style) {
core.ui.setFont(ctx, /*(/\w+/.test(text) ? 'italic ' : '') + */'18px fzchyjw');
core.ui.fillText(ctx, text, x, y, style);

View File

@ -1,325 +1,327 @@
var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
{
"init": function () {
this._afterLoadResources = function () {
// 本函数将在所有资源加载完毕后,游戏开启前被执行
}
core.control.resize = function () {
if (main.mode == 'editor') return;
var clientWidth = main.dom.body.clientWidth, clientHeight = main.dom.body.clientHeight;
var BORDER = 0;
var extendToolbar = core.flags.extendToolbar;
var BAR_WIDTH = extendToolbar ? 0 : Math.round(core._PY_ / 3);
var horizontalMaxRatio = (clientHeight - 2 * BORDER - (extendToolbar ? BORDER : 0)) / (core._PY_ + (extendToolbar ? 38 : 0));
if (clientWidth - 3 * BORDER >= core._PX_ + BAR_WIDTH || (clientWidth > clientHeight && horizontalMaxRatio < 1)) {
// 横屏
core.domStyle.isVertical = false;
core.domStyle.availableScale = [];
[1, 1.25, 1.5, 1.75, 2, 2.25, 2.5].forEach(function (v) {
if (clientWidth - 3 * BORDER >= v * (core._PX_ + BAR_WIDTH) && horizontalMaxRatio >= v) {
core.domStyle.availableScale.push(v);
}
});
if (core.domStyle.availableScale.indexOf(core.domStyle.scale) < 0) {
core.domStyle.scale = Math.min(1, horizontalMaxRatio);
this._afterLoadResources = function () {
// 本函数将在所有资源加载完毕后,游戏开启前被执行
}
core.control.hideStatusBar();
core.control.resize = function () {
if (main.mode == 'editor') return;
var clientWidth = main.dom.body.clientWidth,
clientHeight = main.dom.body.clientHeight;
var BORDER = 0;
var extendToolbar = core.flags.extendToolbar;
var BAR_WIDTH = extendToolbar ? 0 : Math.round(core._PY_ / 3);
var horizontalMaxRatio = (clientHeight - 2 * BORDER - (extendToolbar ? BORDER : 0)) / (core._PY_ + (extendToolbar ? 38 : 0));
if (clientWidth - 3 * BORDER >= core._PX_ + BAR_WIDTH || (clientWidth > clientHeight && horizontalMaxRatio < 1)) {
// 横屏
core.domStyle.isVertical = false;
core.domStyle.availableScale = [];
[1, 1.25, 1.5, 1.75, 2, 2.25, 2.5].forEach(function (v) {
if (clientWidth - 3 * BORDER >= v * (core._PX_ + BAR_WIDTH) && horizontalMaxRatio >= v) {
core.domStyle.availableScale.push(v);
}
});
if (core.domStyle.availableScale.indexOf(core.domStyle.scale) < 0) {
core.domStyle.scale = Math.min(1, horizontalMaxRatio);
}
else {
// 竖屏
core.domStyle.isVertical = true;
core.domStyle.scale = Math.min((clientWidth - 2 * BORDER) / core._PX_);
core.domStyle.availableScale = [];
extendToolbar = false;
BAR_WIDTH = Math.round(core._PX_ * 0.3);
}
var statusDisplayArr = this._shouldDisplayStatus(), count = statusDisplayArr.length;
var statusCanvas = core.flags.statusCanvas, statusCanvasRows = core.values.statusCanvasRowsOnMobile || 3;
var col = statusCanvas ? statusCanvasRows : Math.ceil(count / 3);
if (col > 5) {
if (statusCanvas) alert("自绘状态栏的在竖屏下的行数应不超过5");
else alert("当前状态栏数目(" + count + ")大于15请调整到不超过15以避免手机端出现显示问题。");
}
var globalAttribute = core.status.globalAttribute || core.initStatus.globalAttribute;
var obj = {
clientWidth: clientWidth,
clientHeight: clientHeight,
BORDER: BORDER,
BAR_WIDTH: BAR_WIDTH,
TOOLBAR_HEIGHT: 38,
outerWidth: core._PX_ * core.domStyle.scale + 2 * BORDER,
outerHeight: core._PY_ * core.domStyle.scale + 2 * BORDER,
globalAttribute: globalAttribute,
border: '0px ' + core.arrayToRGBA(globalAttribute.borderColor) + ' solid',
statusDisplayArr: statusDisplayArr,
count: count,
col: col,
statusBarHeightInVertical: core.domStyle.isVertical ? (32 * col + 6) * core.domStyle.scale + 2 * BORDER : 0,
toolbarHeightInVertical: core.domStyle.isVertical ? 38 * core.domStyle.scale + 2 * BORDER : 0,
extendToolbar: extendToolbar,
is15x15: false
};
this._doResize(obj);
this.setToolbarButton();
core.updateStatusBar();
} else {
// 竖屏
core.domStyle.isVertical = true;
core.domStyle.scale = Math.min((clientWidth - 2 * BORDER) / core._PX_);
core.domStyle.availableScale = [];
extendToolbar = false;
BAR_WIDTH = Math.round(core._PX_ * 0.3);
}
core.control._resize_statusBar = function (obj) {
// statusBar
var statusBar = core.dom.statusBar;
if (core.domStyle.isVertical) {
statusBar.style.width = obj.outerWidth + "px";
statusBar.style.height = obj.statusBarHeightInVertical + "px";
statusBar.style.background = obj.globalAttribute.statusTopBackground;
var statusDisplayArr = this._shouldDisplayStatus(),
count = statusDisplayArr.length;
var statusCanvas = core.flags.statusCanvas,
statusCanvasRows = core.values.statusCanvasRowsOnMobile || 3;
var col = statusCanvas ? statusCanvasRows : Math.ceil(count / 3);
if (col > 5) {
if (statusCanvas) alert("自绘状态栏的在竖屏下的行数应不超过5");
else alert("当前状态栏数目(" + count + ")大于15请调整到不超过15以避免手机端出现显示问题。");
}
var globalAttribute = core.status.globalAttribute || core.initStatus.globalAttribute;
var obj = {
clientWidth: clientWidth,
clientHeight: clientHeight,
BORDER: BORDER,
BAR_WIDTH: BAR_WIDTH,
TOOLBAR_HEIGHT: 38,
outerWidth: core._PX_ * core.domStyle.scale + 2 * BORDER,
outerHeight: core._PY_ * core.domStyle.scale + 2 * BORDER,
globalAttribute: globalAttribute,
border: '0px ' + core.arrayToRGBA(globalAttribute.borderColor) + ' solid',
statusDisplayArr: statusDisplayArr,
count: count,
col: col,
statusBarHeightInVertical: core.domStyle.isVertical ? (32 * col + 6) * core.domStyle.scale + 2 * BORDER : 0,
toolbarHeightInVertical: core.domStyle.isVertical ? 38 * core.domStyle.scale + 2 * BORDER : 0,
extendToolbar: extendToolbar,
is15x15: false
};
this._doResize(obj);
this.setToolbarButton();
core.updateStatusBar();
}
core.control._resize_statusBar = function (obj) {
// statusBar
var statusBar = core.dom.statusBar;
if (core.domStyle.isVertical) {
statusBar.style.width = obj.outerWidth + "px";
statusBar.style.height = obj.statusBarHeightInVertical + "px";
statusBar.style.background = obj.globalAttribute.statusTopBackground;
statusBar.style.fontSize = 16 * core.domStyle.scale + "px";
} else {
statusBar.style.width = (obj.BAR_WIDTH * core.domStyle.scale + obj.BORDER) + "px";
statusBar.style.height = obj.outerHeight + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT * core.domStyle.scale + obj.BORDER : 0) + "px";
statusBar.style.background = obj.globalAttribute.statusLeftBackground;
// --- 计算文字大小
if (obj.extendToolbar) {
statusBar.style.fontSize = 16 * core.domStyle.scale + "px";
}
else {
statusBar.style.width = (obj.BAR_WIDTH * core.domStyle.scale + obj.BORDER) + "px";
statusBar.style.height = obj.outerHeight + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT * core.domStyle.scale + obj.BORDER : 0) + "px";
statusBar.style.background = obj.globalAttribute.statusLeftBackground;
// --- 计算文字大小
if (obj.extendToolbar) {
statusBar.style.fontSize = 16 * core.domStyle.scale + "px";
} else {
statusBar.style.fontSize = 16 * Math.min(1, (core._HEIGHT_ - 4) / obj.count) * core.domStyle.scale + "px";
}
}
statusBar.style.display = obj.extendToolbar ? 'none' : 'block';
statusBar.style.borderTop = statusBar.style.borderLeft = obj.border;
statusBar.style.borderRight = core.domStyle.isVertical ? obj.border : '';
statusBar.style.borderBottom = core.domStyle.isVertical ? '' : obj.border;
// 自绘状态栏
if (core.domStyle.isVertical) {
core.dom.statusCanvas.style.width = core._PX_ * core.domStyle.scale + "px";
core.dom.statusCanvas.style.height = obj.statusBarHeightInVertical - 3 + "px";
core.maps._setHDCanvasSize(core.dom.statusCanvasCtx, core._PX_, obj.col * 32 + 9);
}
else {
core.dom.statusCanvas.style.width = obj.BAR_WIDTH * core.domStyle.scale + "px";
core.dom.statusCanvas.style.height = obj.outerHeight - 2 * obj.BORDER + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT * core.domStyle.scale + obj.BORDER : 0) + "px";
core.maps._setHDCanvasSize(core.dom.statusCanvasCtx, obj.BAR_WIDTH, core._PY_ + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT + obj.BORDER : 0));
}
if (core.domStyle.isVertical) {
core.dom.caidan1.style.width = core._PX_ * core.domStyle.scale + "px";
core.dom.caidan1.style.height = obj.statusBarHeightInVertical - 3 + "px";
core.maps._setHDCanvasSize(core.dom.caidan1Ctx, core._PX_, obj.col * 32 + 9);
}
else {
core.dom.caidan1.style.width = obj.BAR_WIDTH * core.domStyle.scale + "px";
core.dom.caidan1.style.height = obj.outerHeight - 2 * obj.BORDER + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT * core.domStyle.scale + obj.BORDER : 0) + "px";
core.maps._setHDCanvasSize(core.dom.caidan1Ctx, obj.BAR_WIDTH, core._PY_ + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT + obj.BORDER : 0));
}
core.dom.statusCanvas.style.display = core.flags.statusCanvas && !obj.extendToolbar ? "block" : "none";
}
core.registerResize("statusBar", core.control._resize_statusBar);
core.control._resize_gameGroup = function (obj) {
var startBackground = core.domStyle.isVertical ? (main.styles.startVerticalBackground || main.styles.startBackground) : main.styles.startBackground;
if (main.dom.startBackground.getAttribute('__src__') != startBackground) {
main.dom.startBackground.setAttribute('__src__', startBackground);
main.dom.startBackground.src = startBackground;
}
var gameGroup = core.dom.gameGroup;
var totalWidth, totalHeight;
if (core.domStyle.isVertical) {
totalWidth = obj.outerWidth;
totalHeight = obj.outerHeight + obj.statusBarHeightInVertical + obj.toolbarHeightInVertical
}
else {
totalWidth = obj.outerWidth + obj.BAR_WIDTH * core.domStyle.scale + (obj.extendToolbar ? 0 : obj.BORDER);
totalHeight = obj.outerHeight + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT * core.domStyle.scale + obj.BORDER : 0);
}
gameGroup.style.width = totalWidth + "px";
gameGroup.style.height = totalHeight + "px";
gameGroup.style.left = (obj.clientWidth - totalWidth) / 2 + "px";
gameGroup.style.top = (obj.clientHeight - totalHeight) / 2 + "px";
gameGroup.style.overflow = "hidden";
var whole = core.dom.whole;
whole.style.width = totalWidth + "px";
whole.style.height = totalHeight + "px";
// floorMsgGroup
var floorMsgGroup = core.dom.floorMsgGroup;
floorMsgGroup.style = obj.globalAttribute.floorChangingStyle;
floorMsgGroup.style.width = obj.outerWidth - 2 * obj.BORDER + "px";
floorMsgGroup.style.height = totalHeight - 2 * obj.BORDER + "px";
floorMsgGroup.style.fontSize = 16 * core.domStyle.scale + "px";
// startPanel
core.dom.startPanel.style.fontSize = 16 * core.domStyle.scale + "px";
// musicBtn
if (core.domStyle.isVertical || core.domStyle.scale < 1) {
core.dom.musicBtn.style.right = core.dom.musicBtn.style.bottom = "3px";
}
else {
core.dom.musicBtn.style.right = (obj.clientWidth - totalWidth) / 2 + "px";
core.dom.musicBtn.style.bottom = (obj.clientHeight - totalHeight) / 2 - 27 + "px";
} else {
statusBar.style.fontSize = 16 * Math.min(1, (core._HEIGHT_ - 4) / obj.count) * core.domStyle.scale + "px";
}
}
core.registerResize("gameGroup", core.control._resize_gameGroup);
core.maps._drawThumbnail_realDrawTempCanvas = function (floorId, blocks, options) {
// 缩略图:背景
this.drawBg(floorId, options);
// 缩略图:事件
this.drawEvents(floorId, blocks, options);
// 缩略图:勇士
if (options.heroLoc) {
options.heroIcon = options.heroIcon || core.status.hero.image || 'hero.png';
options.heroIcon = core.getMappedName(options.heroIcon);
var icon = core.material.icons.hero[options.heroLoc.direction];
var height = core.material.images.images[options.heroIcon].height / 4;
var width = (core.material.images.images[options.heroIcon].width || 128) / 4;
core.drawImage(options.ctx, core.material.images.images[options.heroIcon], icon.stop * width, icon.loc * height, width, height,
32 * options.heroLoc.x + 32 - width, 32 * options.heroLoc.y + 32 - height, width, height);
}
// 缩略图:卷轴
if (floorId != 'nandu') core.drawImage(options.ctx, 'caidan.png', -161, 0);
// 缩略图:前景
this.drawFg(floorId, options);
// 缩略图:显伤
if (options.damage && core.hasItem('book')) {
core.updateCheckBlock(floorId);
core.control.updateDamage(floorId, options.ctx);
statusBar.style.display = obj.extendToolbar ? 'none' : 'block';
statusBar.style.borderTop = statusBar.style.borderLeft = obj.border;
statusBar.style.borderRight = core.domStyle.isVertical ? obj.border : '';
statusBar.style.borderBottom = core.domStyle.isVertical ? '' : obj.border;
// 自绘状态栏
if (core.domStyle.isVertical) {
core.dom.statusCanvas.style.width = core._PX_ * core.domStyle.scale + "px";
core.dom.statusCanvas.style.height = obj.statusBarHeightInVertical - 3 + "px";
core.maps._setHDCanvasSize(core.dom.statusCanvasCtx, core._PX_, obj.col * 32 + 9);
} else {
core.dom.statusCanvas.style.width = obj.BAR_WIDTH * core.domStyle.scale + "px";
core.dom.statusCanvas.style.height = obj.outerHeight - 2 * obj.BORDER + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT * core.domStyle.scale + obj.BORDER : 0) + "px";
core.maps._setHDCanvasSize(core.dom.statusCanvasCtx, obj.BAR_WIDTH, core._PY_ + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT + obj.BORDER : 0));
}
if (core.domStyle.isVertical) {
core.dom.caidan1.style.width = core._PX_ * core.domStyle.scale + "px";
core.dom.caidan1.style.height = obj.statusBarHeightInVertical - 3 + "px";
core.maps._setHDCanvasSize(core.dom.caidan1Ctx, core._PX_, obj.col * 32 + 9);
} else {
core.dom.caidan1.style.width = obj.BAR_WIDTH * core.domStyle.scale + "px";
core.dom.caidan1.style.height = obj.outerHeight - 2 * obj.BORDER + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT * core.domStyle.scale + obj.BORDER : 0) + "px";
core.maps._setHDCanvasSize(core.dom.caidan1Ctx, obj.BAR_WIDTH, core._PY_ + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT + obj.BORDER : 0));
}
core.dom.statusCanvas.style.display = core.flags.statusCanvas && !obj.extendToolbar ? "block" : "none";
}
core.registerResize("statusBar", core.control._resize_statusBar);
core.control._resize_gameGroup = function (obj) {
var startBackground = core.domStyle.isVertical ? (main.styles.startVerticalBackground || main.styles.startBackground) : main.styles.startBackground;
if (main.dom.startBackground.getAttribute('__src__') != startBackground) {
main.dom.startBackground.setAttribute('__src__', startBackground);
main.dom.startBackground.src = startBackground;
}
var gameGroup = core.dom.gameGroup;
var totalWidth, totalHeight;
if (core.domStyle.isVertical) {
totalWidth = obj.outerWidth;
totalHeight = obj.outerHeight + obj.statusBarHeightInVertical + obj.toolbarHeightInVertical
} else {
totalWidth = obj.outerWidth + obj.BAR_WIDTH * core.domStyle.scale + (obj.extendToolbar ? 0 : obj.BORDER);
totalHeight = obj.outerHeight + (obj.extendToolbar ? obj.TOOLBAR_HEIGHT * core.domStyle.scale + obj.BORDER : 0);
}
gameGroup.style.width = totalWidth + "px";
gameGroup.style.height = totalHeight + "px";
gameGroup.style.left = (obj.clientWidth - totalWidth) / 2 + "px";
gameGroup.style.top = (obj.clientHeight - totalHeight) / 2 + "px";
gameGroup.style.overflow = "hidden";
var whole = core.dom.whole;
whole.style.width = totalWidth + "px";
whole.style.height = totalHeight + "px";
// floorMsgGroup
var floorMsgGroup = core.dom.floorMsgGroup;
floorMsgGroup.style = obj.globalAttribute.floorChangingStyle;
floorMsgGroup.style.width = obj.outerWidth - 2 * obj.BORDER + "px";
floorMsgGroup.style.height = totalHeight - 2 * obj.BORDER + "px";
floorMsgGroup.style.fontSize = 16 * core.domStyle.scale + "px";
// startPanel
core.dom.startPanel.style.fontSize = 16 * core.domStyle.scale + "px";
// musicBtn
if (core.domStyle.isVertical || core.domStyle.scale < 1) {
core.dom.musicBtn.style.right = core.dom.musicBtn.style.bottom = "3px";
} else {
core.dom.musicBtn.style.right = (obj.clientWidth - totalWidth) / 2 + "px";
core.dom.musicBtn.style.bottom = (obj.clientHeight - totalHeight) / 2 - 27 + "px";
}
}
core.registerResize("gameGroup", core.control._resize_gameGroup);
core.maps._drawThumbnail_realDrawTempCanvas = function (floorId, blocks, options) {
// 缩略图:背景
this.drawBg(floorId, options);
// 缩略图:事件
this.drawEvents(floorId, blocks, options);
// 缩略图:勇士
if (options.heroLoc) {
options.heroIcon = options.heroIcon || core.status.hero.image || 'hero.png';
options.heroIcon = core.getMappedName(options.heroIcon);
var icon = core.material.icons.hero[options.heroLoc.direction];
var height = core.material.images.images[options.heroIcon].height / 4;
var width = (core.material.images.images[options.heroIcon].width || 128) / 4;
core.drawImage(options.ctx, core.material.images.images[options.heroIcon], icon.stop * width, icon.loc * height, width, height,
32 * options.heroLoc.x + 32 - width, 32 * options.heroLoc.y + 32 - height, width, height);
}
// 缩略图:卷轴
if (floorId != 'nandu') core.drawImage(options.ctx, 'caidan.png', -161, 0);
// 缩略图:前景
this.drawFg(floorId, options);
// 缩略图:显伤
if (options.damage && core.hasItem('book')) {
core.updateCheckBlock(floorId);
core.control.updateDamage(floorId, options.ctx);
}
}
core.maps._drawMap_drawAll = function (floorId, config) {
floorId = floorId || core.status.floorId;
this.drawBg(floorId, config);
this.drawEvents(floorId);
this.drawFg(floorId, config);
if (floorId == "nandu") {
core.maps._drawFloorImages(floorId, core.dom.wholeCtx, 'whole', null, null, (config || {}).onMap);
} else core.dom.wholeCtx.clearRect(0, 0, core.dom.whole.width, core.dom.whole.height);
}
core.control._animationFrame_globalAnimate = function (timestamp) {
if (timestamp - core.animateFrame.globalTime <= core.values.animateSpeed) return;
core.status.globalAnimateStatus++;
if (core.status.floorId) {
// Global Animate
core.status.globalAnimateObjs.forEach(function (block) {
core.drawBlock(block, core.status.globalAnimateStatus);
});
// Global floor images
core.maps._drawFloorImages(core.status.floorId, core.canvas.bg, 'bg', core.status.floorAnimateObjs || [], core.status.globalAnimateStatus);
core.maps._drawFloorImages(core.status.floorId, core.canvas.fg, 'fg', core.status.floorAnimateObjs || [], core.status.globalAnimateStatus);
core.maps._drawFloorImages(core.status.floorId, core.dom.wholeCtx, 'whole', core.status.floorAnimateObjs || [], core.status.globalAnimateStatus);
// Global Autotile Animate
core.status.autotileAnimateObjs.forEach(function (block) {
core.maps._drawAutotileAnimate(block, core.status.globalAnimateStatus);
});
// Global hero animate
if ((core.status.hero || {}).animate && core.status.heroMoving == 0 && main.mode == 'play' && !core.status.preview.enabled) {
core.drawHero('stop', null, core.status.globalAnimateStatus);
}
}
core.maps._drawMap_drawAll = function (floorId, config) {
floorId = floorId || core.status.floorId;
this.drawBg(floorId, config);
this.drawEvents(floorId);
this.drawFg(floorId, config);
if (floorId == "nandu") {
core.maps._drawFloorImages(floorId, core.dom.wholeCtx, 'whole', null, null, (config || {}).onMap);
}
else core.dom.wholeCtx.clearRect(0, 0, core.dom.whole.width, core.dom.whole.height);
// Box animate
core.drawBoxAnimate();
core.animateFrame.globalTime = timestamp;
}
core.control.registerAnimationFrame("globalAnimate", true, core.control._animationFrame_globalAnimate);
core.ui.createCanvas2 = function (name, x, y, width, height, z) {
// 如果画布已存在则直接调用
if (core.dymCanvas[name]) {
core.deleteCanvas(name);
}
core.control._animationFrame_globalAnimate = function (timestamp) {
if (timestamp - core.animateFrame.globalTime <= core.values.animateSpeed) return;
core.status.globalAnimateStatus++;
if (core.status.floorId) {
// Global Animate
core.status.globalAnimateObjs.forEach(function (block) {
core.drawBlock(block, core.status.globalAnimateStatus);
});
// Global floor images
core.maps._drawFloorImages(core.status.floorId, core.canvas.bg, 'bg', core.status.floorAnimateObjs || [], core.status.globalAnimateStatus);
core.maps._drawFloorImages(core.status.floorId, core.canvas.fg, 'fg', core.status.floorAnimateObjs || [], core.status.globalAnimateStatus);
core.maps._drawFloorImages(core.status.floorId, core.dom.wholeCtx, 'whole', core.status.floorAnimateObjs || [], core.status.globalAnimateStatus);
// Global Autotile Animate
core.status.autotileAnimateObjs.forEach(function (block) {
core.maps._drawAutotileAnimate(block, core.status.globalAnimateStatus);
});
// Global hero animate
if ((core.status.hero || {}).animate && core.status.heroMoving == 0 && main.mode == 'play' && !core.status.preview.enabled) {
core.drawHero('stop', null, core.status.globalAnimateStatus);
}
}
// Box animate
core.drawBoxAnimate();
core.animateFrame.globalTime = timestamp;
}
core.control.registerAnimationFrame("globalAnimate", true, core.control._animationFrame_globalAnimate);
core.ui.createCanvas2 = function (name, x, y, width, height, z) {
// 如果画布已存在则直接调用
if (core.dymCanvas[name]) {
core.deleteCanvas(name);
}
var newCanvas = document.createElement("canvas");
newCanvas.id = name;
newCanvas.style.display = 'block';
newCanvas.setAttribute("_left", x);
newCanvas.setAttribute("_top", y);
newCanvas.style.width = width * core.domStyle.scale + 'px';
newCanvas.style.height = height * core.domStyle.scale + 'px';
newCanvas.style.left = x * core.domStyle.scale + 'px';
newCanvas.style.top = y * core.domStyle.scale + 'px';
newCanvas.style.zIndex = z;
newCanvas.style.position = 'absolute';
newCanvas.style.pointerEvents = 'none';
core.dymCanvas[name] = newCanvas.getContext('2d');
core.maps._setHDCanvasSize(core.dymCanvas[name], width, height);
core.dom.gameGroup.appendChild(newCanvas);
return core.dymCanvas[name];
}
core.ui.deleteCanvas = function (name) {
if (name instanceof Function) {
Object.keys(core.dymCanvas).forEach(function (one) {
if (name(one)) core.deleteCanvas(one);
});
return;
}
if (!core.dymCanvas[name]) return null;
var temp = core.dymCanvas[name].canvas.parentElement.id;
if (temp == "gameDraw") core.dom.gameDraw.removeChild(core.dymCanvas[name].canvas);
if (temp == "gameGroup") core.dom.gameGroup.removeChild(core.dymCanvas[name].canvas);
delete core.dymCanvas[name];
}
core.events.showImage2 = function (code, image, sloc, loc, opacityVal, time, callback) {
var imageName = null;
if (typeof image == 'string') {
imageName = image;
if (image.endsWith(':x') || image.endsWith(':y') || image.endsWith(':o')) {
image = image.substring(0, image.length - 2);
}
image = core.getMappedName(image);
image = core.material.images.images[image];
}
if (!image) {
if (callback) callback();
return;
}
sloc = sloc || [];
var sx = core.calValue(sloc[0]) || 0, sy = core.calValue(sloc[1]) || 0;
var sw = core.calValue(sloc[2]), sh = core.calValue(sloc[3]);
if (sw == null) sw = image.width;
if (sh == null) sh = image.height;
loc = loc || [];
var x = core.calValue(loc[0]) || 0, y = core.calValue(loc[1]) || 0;
var w = core.calValue(loc[2]), h = core.calValue(loc[3]);
if (w == null) w = sw;
if (h == null) h = sh;
var zIndex = code + 100;
time = time || 0;
var name = "image" + zIndex;
var ctx = core.ui.createCanvas2(name, x, y, w, h, zIndex);
core.drawImage(ctx, imageName == null ? image : imageName, sx, sy, sw, sh, 0, 0, w, h);
if (time == 0) {
core.setOpacity(name, opacityVal);
if (callback) callback();
return;
}
core.setOpacity(name, 0);
this.moveImage(code, null, opacityVal, null, time, callback);
}
core.events._action_showImage2 = function (data, x, y, prefix) {
if (core.isReplaying()) data.time = 0;
this.__action_doAsyncFunc(data.async || data.time == 0, core.events.showImage2,
data.code, data.image + (data.reverse || ''), data.sloc, data.loc, data.opacity, data.time);
}
core.ui._drawCenterFly = function () {
core.lockControl();
core.status.event.id = 'centerFly';
var fillstyle = 'rgba(255,0,0,0.5)';
if (core.canUseItem('centerFly')) fillstyle = 'rgba(0,255,0,0.5)';
var toX = core.bigmap.width - 1 - core.getHeroLoc('x'), toY = core.bigmap.height - 3 - core.getHeroLoc('y');
this.clearUI();
core.fillRect('ui', 0, 0, core._PX_, core._PY_, '#000000');
core.drawThumbnail(null, null, { heroLoc: core.status.hero.loc, heroIcon: core.status.hero.image, ctx: 'ui', centerX: toX, centerY: toY });
var offsetX = core.clamp(toX - core._HALF_WIDTH_, 0, core.bigmap.width - core._WIDTH_),
offsetY = core.clamp(toY - core._HALF_HEIGHT_, 0, core.bigmap.height - core._HEIGHT_);
core.fillRect('ui', (toX - offsetX) * 32, (toY - offsetY) * 32, 32, 32, fillstyle);
core.status.event.data = { "x": toX, "y": toY, "posX": toX - offsetX, "posY": toY - offsetY };
core.playSound('打开界面');
core.drawTip("请确认当前" + core.material.items['centerFly'].name + "的位置", 'centerFly');
var newCanvas = document.createElement("canvas");
newCanvas.id = name;
newCanvas.style.display = 'block';
newCanvas.setAttribute("_left", x);
newCanvas.setAttribute("_top", y);
newCanvas.style.width = width * core.domStyle.scale + 'px';
newCanvas.style.height = height * core.domStyle.scale + 'px';
newCanvas.style.left = x * core.domStyle.scale + 'px';
newCanvas.style.top = y * core.domStyle.scale + 'px';
newCanvas.style.zIndex = z;
newCanvas.style.position = 'absolute';
newCanvas.style.pointerEvents = 'none';
core.dymCanvas[name] = newCanvas.getContext('2d');
core.maps._setHDCanvasSize(core.dymCanvas[name], width, height);
core.dom.gameGroup.appendChild(newCanvas);
return core.dymCanvas[name];
}
core.ui.deleteCanvas = function (name) {
if (name instanceof Function) {
Object.keys(core.dymCanvas).forEach(function (one) {
if (name(one)) core.deleteCanvas(one);
});
return;
}
},
if (!core.dymCanvas[name]) return null;
var temp = core.dymCanvas[name].canvas.parentElement.id;
if (temp == "gameDraw") core.dom.gameDraw.removeChild(core.dymCanvas[name].canvas);
if (temp == "gameGroup") core.dom.gameGroup.removeChild(core.dymCanvas[name].canvas);
delete core.dymCanvas[name];
}
core.events.showImage2 = function (code, image, sloc, loc, opacityVal, time, callback) {
var imageName = null;
if (typeof image == 'string') {
imageName = image;
if (image.endsWith(':x') || image.endsWith(':y') || image.endsWith(':o')) {
image = image.substring(0, image.length - 2);
}
image = core.getMappedName(image);
image = core.material.images.images[image];
}
if (!image) {
if (callback) callback();
return;
}
sloc = sloc || [];
var sx = core.calValue(sloc[0]) || 0,
sy = core.calValue(sloc[1]) || 0;
var sw = core.calValue(sloc[2]),
sh = core.calValue(sloc[3]);
if (sw == null) sw = image.width;
if (sh == null) sh = image.height;
loc = loc || [];
var x = core.calValue(loc[0]) || 0,
y = core.calValue(loc[1]) || 0;
var w = core.calValue(loc[2]),
h = core.calValue(loc[3]);
if (w == null) w = sw;
if (h == null) h = sh;
var zIndex = code + 100;
time = time || 0;
var name = "image" + zIndex;
var ctx = core.ui.createCanvas2(name, x, y, w, h, zIndex);
core.drawImage(ctx, imageName == null ? image : imageName, sx, sy, sw, sh, 0, 0, w, h);
if (time == 0) {
core.setOpacity(name, opacityVal);
if (callback) callback();
return;
}
core.setOpacity(name, 0);
this.moveImage(code, null, opacityVal, null, time, callback);
}
core.events._action_showImage2 = function (data, x, y, prefix) {
if (core.isReplaying()) data.time = 0;
this.__action_doAsyncFunc(data.async || data.time == 0, core.events.showImage2,
data.code, data.image + (data.reverse || ''), data.sloc, data.loc, data.opacity, data.time);
}
core.ui._drawCenterFly = function () {
core.lockControl();
core.status.event.id = 'centerFly';
var fillstyle = 'rgba(255,0,0,0.5)';
if (core.canUseItem('centerFly')) fillstyle = 'rgba(0,255,0,0.5)';
var toX = core.bigmap.width - 1 - core.getHeroLoc('x'),
toY = core.bigmap.height - 3 - core.getHeroLoc('y');
this.clearUI();
core.fillRect('ui', 0, 0, core._PX_, core._PY_, '#000000');
core.drawThumbnail(null, null, { heroLoc: core.status.hero.loc, heroIcon: core.status.hero.image, ctx: 'ui', centerX: toX, centerY: toY });
var offsetX = core.clamp(toX - core._HALF_WIDTH_, 0, core.bigmap.width - core._WIDTH_),
offsetY = core.clamp(toY - core._HALF_HEIGHT_, 0, core.bigmap.height - core._HEIGHT_);
core.fillRect('ui', (toX - offsetX) * 32, (toY - offsetY) * 32, 32, 32, fillstyle);
core.status.event.data = { "x": toX, "y": toY, "posX": toX - offsetX, "posY": toY - offsetY };
core.playSound('打开界面');
core.drawTip("请确认当前" + core.material.items['centerFly'].name + "的位置", 'centerFly');
return;
}
},
"drawLight": function () {
// 绘制灯光/漆黑层效果。调用方式 core.plugin.drawLight(...)
@ -2180,5 +2182,64 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.events._changeFloor_afterChange(info, callback);
});*/
}
},
"标题动画": function () {
var start = document.getElementById('startPanel');
var list = [];
var id = 0;
// 标题
var title = document.getElementById('startTitle');
core.registerResize('startTitle', function () {
title.style.width = 300 * core.domStyle.scale + 'px';
title.style.height = 187 * core.domStyle.scale + 'px';
});
// 星星动画使用sprite化方法
function draw() {
if (start.style.display === 'none') return;
// 每帧有10%的概率出
if (Math.random() < 0.1) {
var config = {
x: Math.random() * 450 * core.domStyle.scale,
y: -187 * core.domStyle.scale,
id: id++
};
if (id > 100) id -= 100;
list.push(config);
// 追加新的ele
var img = document.createElement('img');
img.src = './project/images/Title_starlong.png';
img.style.position = 'absolute';
img.style.zIndex = '280';
img.style.left = config.x + 'px';
img.style.top = '0px';
img.style.transform = 'scale(' + core.domStyle.scale * 100 + '%)'
img.id = id + '_star';
list[list.length - 1].ele = img;
start.appendChild(img);
}
update();
}
// 每帧更新动画
function update() {
for (var i = 0; i < list.length; i++) {
// 一定要匀速运动
var one = list[i];
if (one.x < -154 * core.domStyle.scale) {
list.splice(i, 1);
i--;
one.ele.remove();
continue;
}
one.x -= 3 * core.domStyle.scale;
one.y += 3 * core.domStyle.scale;
one.ele.style.top = one.y + 'px';
one.ele.style.left = one.x + 'px';
}
}
core.registerAnimationFrame('startAnimation', false, draw);
}
}