Merge pull request #260 from ckcz123/v2.0

V2.0
This commit is contained in:
Zhang Chen 2018-11-23 14:20:35 +08:00 committed by GitHub
commit 5b6321d2c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 37 deletions

View File

@ -928,19 +928,23 @@ editor_mode = function (editor) {
}
var ysize = selectAppend.value.indexOf('48') === -1 ? 32 : 48;
var height = editor_mode.appendPic.toImg.height;
for (var ii = 0, v; v = editor_mode.appendPic.selectPos[ii]; ii++) {
var imgData = source_ctx.getImageData(v.x * 32, v.y * ysize, 32, ysize);
sprite_ctx.putImageData(imgData, ii * 32, height);
// var imgData = source_ctx.getImageData(v.x * 32, v.y * ysize, 32, ysize);
// sprite_ctx.putImageData(imgData, ii * 32, sprite.height - ysize);
// sprite_ctx.drawImage(editor_mode.appendPic.img, v.x * 32, v.y * ysize, 32, ysize, ii * 32, height, 32, ysize)
sprite_ctx.drawImage(source_ctx.canvas, v.x*32, v.y*ysize, 32, ysize, 32*ii, sprite.height - ysize, 32, ysize);
}
var dt = sprite_ctx.getImageData(0, 0, sprite.width, sprite.height);
var imgbase64 = sprite.toDataURL().split(',')[1];
fs.writeFile('./project/images/' + editor_mode.appendPic.imageName + '.png', imgbase64, 'base64', function (err, data) {
if (err) {
printe(err);
throw(err)
}
printe('追加素材成功,请F5刷新编辑器');
printe('追加素材成功请F5刷新编辑器或继续追加当前素材');
sprite.style.height = (sprite.height = (sprite.height+ysize)) + "px";
sprite_ctx.putImageData(dt, 0, 0);
});
}

View File

@ -1234,7 +1234,7 @@ text为提示文字可以在这里给输入提示文字。这里同样可以
``` js
"x,y": [ // 实际执行的事件列表
{"type": "swtich", "condition": "...", // 计算某个表达式
{"type": "switch", "condition": "...", // 计算某个表达式
"caseList": [
{"case": "a", "action": [// 若表达式的值等于a则执行该处事件
@ -1282,7 +1282,7 @@ text为提示文字可以在这里给输入提示文字。这里同样可以
需要额外注意的几点:
- 各个条件分支的判断是顺序执行的,因此若多个分支的条件都满足,将只执行最靠前的分支,同理,请不要在`"default"`分支后添加分支,这些分支将不可能被执行。
- 各个条件分支的判断是顺序执行的,因此若多个分支的条件都满足,将只执行最靠前的分支,同理,请不要在`default`分支后添加分支,这些分支将不可能被执行。
- `default`分支并不是必要的,如果删除,则在没有满足条件的分支时将不执行任何事件。
- 即使某个场合不执行事件对应的action数组也需要存在不过简单的留空就好。
- switch可以不断进行嵌套一层套一层如某条件成立的场合再进行另一个switch判断等。

View File

@ -1819,10 +1819,16 @@ actions.prototype.clickSwitchs = function (x,y) {
core.ui.drawSwitchs();
break;
case 8:
window.open(core.platform.isPC?"editor.html":"editor-mobile.html", "_blank");
if (core.platform.isPC)
window.open("editor.html", "_blank");
else
window.location.href = "editor-mobile.html";
break;
case 9:
window.open(core.firstData.name+".zip", "_blank");
if (core.platform.isPC)
window.open(core.firstData.name+".zip");
else
window.location.href = core.firstData.name+".zip";
break;
case 10:
core.status.event.selection=0;

View File

@ -1536,15 +1536,9 @@ control.prototype.updateDamage = function (floorId, canvas) {
if (core.isset(mapBlocks[b].event) && mapBlocks[b].event.cls.indexOf('enemy')==0
&& !mapBlocks[b].disable) {
// 非系统默认的战斗事件(被覆盖)
if (mapBlocks[b].event.trigger != 'battle') {
// 判断显伤
var event = core.floors[floorId].events[x+","+y];
if (core.isset(event) && !(event instanceof Array)) {
if (event.displayDamage === false)
continue;
}
}
// 判定是否显伤
if (mapBlocks[b].event.displayDamage === false)
continue;
var id = mapBlocks[b].event.id;

View File

@ -123,28 +123,20 @@ maps.prototype.addEvent = function (block, x, y, event) {
if (!core.isset(event.data))
event.data = [];
// 覆盖noPass
if (core.isset(event.noPass))
block.event.noPass = event.noPass;
// 覆盖enable
if (!core.isset(block.disable) && core.isset(event.enable)) {
block.disable=!event.enable;
}
// 覆盖trigger
if (!core.isset(block.event.trigger)) {
if (core.isset(event.trigger)) block.event.trigger=event.trigger;
else block.event.trigger='action';
}
else if (core.isset(event.trigger) && event.trigger!='checkBlock') {
block.event.trigger=event.trigger;
}
// 覆盖其他属性
// 覆盖所有属性
for (var key in event) {
if (key!="disable" && key!="trigger" && key!="noPass" && core.isset(event[key])) {
if (key!="enable" && core.isset(event[key])) {
block.event[key]=core.clone(event[key]);
}
}
// 给无trigger的增加trigger:action
if (!core.isset(block.event.trigger)) {
block.event.trigger = 'action';
}
}
////// 向该楼层添加剧本的楼层转换事件 //////

View File

@ -4,10 +4,35 @@ utils.js 工具类
*/
function utils() {
this.init();
}
utils.prototype.init = function () {
// 定义Object.assign
if (typeof Object.assign != "function") {
Object.assign = function(target, varArgs) { // .length of function is 2
if (target == null) { // TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource != null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
};
}
}
@ -800,12 +825,12 @@ utils.prototype.decodeCanvas = function (arr, width, height) {
}
utils.prototype.consoleOpened = function () {
if (window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized)
return true;
var threshold = 160;
var widthThreshold = window.outerWidth - window.innerWidth > threshold;
var heightThreshold = window.outerHeight - window.innerHeight > threshold;
return !(heightThreshold && widthThreshold) &&
((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized)
|| widthThreshold || heightThreshold);
var zoom = Math.min(window.outerWidth/window.innerWidth, window.outerHeight/window.innerHeight);
return window.outerWidth - zoom*window.innerWidth > threshold
|| window.outerHeight - zoom*window.innerHeight > threshold;
}
utils.prototype.hashCode = function (obj) {