From b36e1bae30df62ac080c0e53145a68a2d9921442 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 27 Sep 2018 14:23:48 +0800 Subject: [PATCH 1/9] Muliple Animations --- _server/editor.js | 5 +++- libs/control.js | 13 ++++++++ libs/core.js | 2 ++ libs/maps.js | 75 ++++++++++++++++++++++++----------------------- 更新说明.txt | 15 +++++++++- 5 files changed, 72 insertions(+), 38 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 937d5dd0..07b714ba 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -114,7 +114,10 @@ editor.prototype.idsInit = function (maps, icons) { var img = core.material.images.tilesets[imgName]; var width = Math.floor(img.width/32), height = Math.floor(img.height/32); if(img.width%32 || img.height%32){ - alert(imgName+'的长或宽不是32的整数倍, 请修改后刷新页面') + alert(imgName+'的长或宽不是32的整数倍, 请修改后刷新页面'); + } + if(img.width*img.height > 32*32*1000){ + alert(imgName+'上的图块数量超过了1000,请修改后刷新页面'); } for (var id=startOffset; id50 && core.isset(core.status.animateObjs) && core.status.animateObjs.length>0) { + core.clearMap('animate'); + core.status.animateObjs = core.status.animateObjs.filter(function (obj) { + return obj.index < obj.animate.frames.length; + }) + core.status.animateObjs.forEach(function (obj) { + core.maps.drawAnimateFrame(obj.animate, obj.centerX, obj.centerY, obj.index++); + }) + core.animateFrame.animateTime = timestamp; + } + // Hero move if (timestamp-core.animateFrame.moveTime>16 && core.isset(core.status.heroMoving) && core.status.heroMoving>0) { var x=core.getHeroLoc('x'), y=core.getHeroLoc('y'), direction = core.getHeroLoc('direction'); diff --git a/libs/core.js b/libs/core.js index 0c8ec1c2..a4157709 100644 --- a/libs/core.js +++ b/libs/core.js @@ -31,6 +31,7 @@ function core() { 'globalAnimate': false, 'globalTime': null, 'boxTime': null, + 'animateTime': null, 'moveTime': null, 'speed': null, 'weather': { @@ -157,6 +158,7 @@ function core() { // 动画 'globalAnimateObjs': [], 'boxAnimateObjs': [], + 'animateObjs': [], }; this.status = {}; } diff --git a/libs/maps.js b/libs/maps.js index 8c6157aa..71e9cd30 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -1180,6 +1180,35 @@ maps.prototype.drawBoxAnimate = function () { } } +////// 绘制动画的某一帧 ////// +maps.prototype.drawAnimateFrame = function (animate, centerX, centerY, index) { + var frame = animate.frames[index]; + var ratio = animate.ratio; + frame.forEach(function (t) { + var image = animate.images[t.index]; + if (!core.isset(image)) return; + var realWidth = image.width * ratio * t.zoom / 100; + var realHeight = image.height * ratio * t.zoom / 100; + core.setAlpha('animate', t.opacity / 255); + + var cx = centerX+t.x, cy=centerY+t.y; + + if (!t.mirror && !t.angle) { + core.canvas.animate.drawImage(image, cx-realWidth/2 - core.bigmap.offsetX, cy-realHeight/2 - core.bigmap.offsetY, realWidth, realHeight); + } + else { + core.saveCanvas('animate'); + core.canvas.animate.translate(cx,cy); + if (t.angle) + core.canvas.animate.rotate(-t.angle*Math.PI/180); + if (t.mirror) + core.canvas.animate.scale(-1,1); + core.canvas.animate.drawImage(image, -realWidth/2 - core.bigmap.offsetX, -realHeight/2 - core.bigmap.offsetY, realWidth, realHeight); + core.loadCanvas('animate'); + } + }) +} + ////// 绘制动画 ////// maps.prototype.drawAnimate = function (name, x, y, callback) { @@ -1195,49 +1224,22 @@ maps.prototype.drawAnimate = function (name, x, y, callback) { return; } - // 清空animate层 clearInterval(core.interval.animateInterval); - core.clearMap('animate'); // 开始绘制 - var animate = core.material.animates[name]; - var ratio = animate.ratio; - var centerX = 32*x+16, centerY = 32*y+16; - var index=0; - + var animate = core.material.animates[name], centerX = 32*x+16, centerY = 32*y+16; // 播放音效 core.playSound(animate.se); - var draw = function (index) { - core.clearMap('animate'); - - var frame = animate.frames[index]; - frame.forEach(function (t) { - var image = animate.images[t.index]; - if (!core.isset(image)) return; - var realWidth = image.width * ratio * t.zoom / 100; - var realHeight = image.height * ratio * t.zoom / 100; - core.setAlpha('animate', t.opacity / 255); - - var cx = centerX+t.x, cy=centerY+t.y; - - if (!t.mirror && !t.angle) { - core.canvas.animate.drawImage(image, cx-realWidth/2 - core.bigmap.offsetX, cy-realHeight/2 - core.bigmap.offsetY, realWidth, realHeight); - } - else { - core.saveCanvas('animate'); - core.canvas.animate.translate(cx,cy); - if (t.angle) - core.canvas.animate.rotate(-t.angle*Math.PI/180); - if (t.mirror) - core.canvas.animate.scale(-1,1); - core.canvas.animate.drawImage(image, -realWidth/2 - core.bigmap.offsetX, -realHeight/2 - core.bigmap.offsetY, realWidth, realHeight); - core.loadCanvas('animate'); - } - }) + // 异步绘制:使用requestAnimationFrame进行绘制 + if (!core.isset(callback)) { + core.status.animateObjs.push({"animate": animate, "centerX": centerX, "centerY": centerY, "index": 0}); + return; } - draw(index++); + var index=0; + core.clearMap('animate'); + core.maps.drawAnimateFrame(animate, centerX, centerY, index++); core.interval.animateInterval = setInterval(function (t) { if (index == animate.frames.length) { @@ -1247,7 +1249,8 @@ maps.prototype.drawAnimate = function (name, x, y, callback) { if (core.isset(callback)) callback(); return; } - draw(index++); + core.clearMap('animate'); + core.maps.drawAnimateFrame(animate, centerX, centerY, index++); }, 50); } diff --git a/更新说明.txt b/更新说明.txt index 64e7c28e..be127ade 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -1,4 +1,17 @@ -HTML5魔塔样板V2.4.1 +HTML5魔塔样板V2.4.2 + +允许导入tilesets直接使用,无需PS和注册 +tilesets的素材允许以矩形方式整体绘制 +增加了透明块的支持 +装备允许按照百分比增加属性 +多动画的同时播放 +修复了打开存读档页面时闪屏的问题 +修复了cannotMove仍然能轻按和瞬移的问题 +所有已知Bug修复,部分代码重构和细节优化 + +----------------------------------------------------------------------- + +HTML5魔塔样板V2.4.1 增加背景层和前景层的图块绘制,多层图块可叠加 背景层/前景层图块的显示、隐藏、修改等事件 From e927c9ea9ce6e968797cd46332d9cee8016de362 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 27 Sep 2018 14:41:59 +0800 Subject: [PATCH 2/9] Number 17: Airwall --- _server/blockly/MotaAction.g4 | 16 ++++++++-------- libs/maps.js | 13 ++++++++++--- libs/ui.js | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 48850a17..d6e6efbe 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -802,7 +802,7 @@ return code; */; viberate_s - : '画面震动' '时间' Int '异步' Bool Newline + : '画面震动' '时间' Int '不等待执行完毕' Bool Newline /* viberate_s @@ -817,7 +817,7 @@ return code; */; animate_s - : '显示动画' IdString '位置' EvalString? '异步' Bool Newline + : '显示动画' IdString '位置' EvalString? '不等待执行完毕' Bool Newline /* animate_s @@ -867,7 +867,7 @@ return code; */; animateImage_0_s - : '图片淡入' EvalString '起点像素位置' 'x' PosString 'y' PosString '动画时间' Int '异步' Bool Newline + : '图片淡入' EvalString '起点像素位置' 'x' PosString 'y' PosString '动画时间' Int '不等待执行完毕' Bool Newline /* animateImage_0_s @@ -881,7 +881,7 @@ return code; */; animateImage_1_s - : '图片淡出' EvalString '起点像素位置' 'x' PosString 'y' PosString '动画时间' Int '异步' Bool Newline + : '图片淡出' EvalString '起点像素位置' 'x' PosString 'y' PosString '动画时间' Int '不等待执行完毕' Bool Newline /* animateImage_1_s @@ -921,7 +921,7 @@ return code; moveImage_0_s : '图片移动' EvalString '起点像素位置' 'x' PosString 'y' PosString BGNL - '终点像素位置' 'x' PosString 'y' PosString '移动时间' Int '异步' Bool Newline + '终点像素位置' 'x' PosString 'y' PosString '移动时间' Int '不等待执行完毕' Bool Newline /* moveImage_0_s @@ -935,7 +935,7 @@ return code; */; setFg_0_s - : '更改画面色调' Number ',' Number ',' Number ',' Number '动画时间' Int? '异步' Bool Newline + : '更改画面色调' Number ',' Number ',' Number ',' Number '动画时间' Int? '不等待执行完毕' Bool Newline /* setFg_0_s @@ -959,7 +959,7 @@ return code; */; setFg_1_s - : '恢复画面色调' '动画时间' Int? '异步' Bool Newline + : '恢复画面色调' '动画时间' Int? '不等待执行完毕' Bool Newline /* setFg_1_s @@ -1110,7 +1110,7 @@ return code; */; setVolume_s - : '设置音量' Int '渐变时间' Int? '异步' Bool Newline + : '设置音量' Int '渐变时间' Int? '不等待执行完毕' Bool Newline /* setVolume_s diff --git a/libs/maps.js b/libs/maps.js index 71e9cd30..c40f254c 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -59,7 +59,10 @@ maps.prototype.initBlock = function (x, y, id) { var tmp = {'x': x, 'y': y, 'id': id}; if (disable!=null) tmp.disable = disable; - if (id in this.blocksInfo) tmp.event = JSON.parse(JSON.stringify(this.blocksInfo[id])); + if (id==17) { + tmp.event = {"cls": "terrains", "id": "airwall", "noPass": true}; + } + else if (id in this.blocksInfo) tmp.event = JSON.parse(JSON.stringify(this.blocksInfo[id])); else { var tilesetOffset = core.icons.getTilesetOffset(id); if (tilesetOffset != null) { @@ -338,9 +341,13 @@ maps.prototype.canMoveDirectly = function (destX,destY) { } maps.prototype.drawBlock = function (block, animate, dx, dy) { + // none:空地;17:空气墙 + if (block.event.id=='none' || block.id==17) return; + var cls = block.event.cls, height = block.event.height || 32; var image, x, y; + if (cls == 'tileset') { var offset = core.icons.getTilesetOffset(block.event.id); if (offset == null) return; @@ -393,7 +400,7 @@ maps.prototype.drawBgFgMap = function (floorId, canvas, name) { for (var y = 0; y < height; y++) { if (name=='bg') canvas.drawImage(blockImage, 0, blockIcon * 32, 32, 32, x * 32, y * 32, 32, 32); - if (arr[y][x]>0) { + if (arr[y][x]>0 && arr[y][x]!=17) { var block = core.maps.initBlock(x, y, arr[y][x]); if (core.isset(block.event)) { var id = block.event.id, cls = block.event.cls; @@ -492,7 +499,7 @@ maps.prototype.drawMap = function (mapName, callback) { if (block.event.cls == 'autotile') { core.drawAutotile(core.canvas.event, mapArray, block, 32, 0, 0); } - else if (block.event.id!='none') { + else { core.drawBlock(block); core.addGlobalAnimate(block); } diff --git a/libs/ui.js b/libs/ui.js index afa4fb39..d728c1a1 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2057,7 +2057,7 @@ ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, cente } } else { - if (block.event.id!='none') { + if (block.event.id!='none' && block.id!=17) { var blockIcon = core.material.icons[block.event.cls][block.event.id]; var blockImage = core.material.images[block.event.cls]; var height = block.event.height || 32; From be3925cae6d7b643b6b6e40bbcadf24c99bb607d Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Thu, 27 Sep 2018 14:44:32 +0800 Subject: [PATCH 3/9] editor: tileset draw-mod --- _server/editor.js | 31 +++++++++++++++++++++++++------ editor-mobile.html | 1 + editor.html | 4 +++- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 937d5dd0..3bb981c8 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -1,6 +1,6 @@ function editor() { this.version = "2.0"; - this.brushMod = "line";//["line","rectangle"] + this.brushMod = "line";//["line","rectangle","tileset"] this.layerMod = "map";//["fgmap","map","bgmap"] this.isMobile = false; } @@ -468,7 +468,7 @@ editor.prototype.listen = function () { }); var unselect=true; - for(var ii=0,thisId;thisId=['edit','tip','brushMod','brushMod2','layerMod','layerMod2','layerMod3','viewportButtons'][ii];ii++){ + for(var ii=0,thisId;thisId=['edit','tip','brushMod','brushMod2','brushMod3','layerMod','layerMod2','layerMod3','viewportButtons'][ii];ii++){ if (clickpath.indexOf(thisId) !== -1){ unselect=false; break; @@ -625,7 +625,7 @@ editor.prototype.listen = function () { e.stopPropagation(); if (stepPostfix && stepPostfix.length) { preMapData = JSON.parse(JSON.stringify({map:editor.map,fgmap:editor.fgmap,bgmap:editor.bgmap})); - if(editor.brushMod==='rectangle'){ + if(editor.brushMod!=='line'){ var x0=stepPostfix[0].x; var y0=stepPostfix[0].y; var x1=stepPostfix[stepPostfix.length-1].x; @@ -633,8 +633,8 @@ editor.prototype.listen = function () { if(x0>x1){x0^=x1;x1^=x0;x0^=x1;}//swap if(y0>y1){y0^=y1;y1^=y0;y0^=y1;}//swap stepPostfix=[]; - for(var ii=x0;ii<=x1;ii++){ - for(var jj=y0;jj<=y1;jj++){ + for(var jj=y0;jj<=y1;jj++){ + for(var ii=x0;ii<=x1;ii++){ stepPostfix.push({x:ii,y:jj}) } } @@ -646,8 +646,22 @@ editor.prototype.listen = function () { if (editor.layerMod!='map' && editor.info.images && editor.info.images.indexOf('48')!==-1){ printe('前景/背景不支持48的图块'); } else { - for (var ii = 0; ii < stepPostfix.length; ii++) + if(editor.brushMod==='tileset' && core.tilesets.indexOf(editor.info.images)!==-1){ + var imgWidth=~~(core.material.images.tilesets[editor.info.images].width/32); + var x0=stepPostfix[0].x; + var y0=stepPostfix[0].y; + var idnum=editor.info.idnum; + for (var ii = 0; ii < stepPostfix.length; ii++){ + if(stepPostfix[ii].y!=y0){ + y0++; + idnum+=imgWidth; + } + editor[editor.layerMod][stepPostfix[ii].y][stepPostfix[ii].x] = editor.ids[editor.indexs[idnum+stepPostfix[ii].x-x0]]; + } + } else { + for (var ii = 0; ii < stepPostfix.length; ii++) editor[editor.layerMod][stepPostfix[ii].y][stepPostfix[ii].x] = editor.info; + } } // console.log(editor.map); editor.updateMap(); @@ -1013,6 +1027,11 @@ editor.prototype.listen = function () { editor.brushMod=brushMod2.value; } + var brushMod3=document.getElementById('brushMod3'); + if(brushMod3)brushMod3.onchange=function(){ + editor.brushMod=brushMod3.value; + } + var layerMod=document.getElementById('layerMod'); layerMod.onchange=function(){ editor.layerMod=layerMod.value; diff --git a/editor-mobile.html b/editor-mobile.html index 5aaa217f..992e6053 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -276,6 +276,7 @@ - +
+ 画线 画矩形 + tileset贴图
From b8f726aac5d0b7ea193e384fb88ef2672d37e45f Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 27 Sep 2018 17:42:16 +0800 Subject: [PATCH 4/9] Number 17: Airwall --- libs/maps.js | 32 +++++++++++++++++++++++++++----- libs/ui.js | 15 +++++++++------ 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/libs/maps.js b/libs/maps.js index c40f254c..0ccd3926 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -341,8 +341,8 @@ maps.prototype.canMoveDirectly = function (destX,destY) { } maps.prototype.drawBlock = function (block, animate, dx, dy) { - // none:空地;17:空气墙 - if (block.event.id=='none' || block.id==17) return; + // none:空地 + if (block.event.id=='none') return; var cls = block.event.cls, height = block.event.height || 32; @@ -354,9 +354,14 @@ maps.prototype.drawBlock = function (block, animate, dx, dy) { image = core.material.images.tilesets[offset.image]; x = offset.x; y = offset.y; - height = 32; } else if (cls == 'autotile') return; + // 空气墙的单独处理 + else if (block.id==17) { + if (!core.isset(core.material.images.airwall)) return; + image = core.material.images.airwall; + x = y = 0; + } else { image = core.material.images[cls]; x = (animate||0)%(block.event.animate||1); @@ -400,7 +405,7 @@ maps.prototype.drawBgFgMap = function (floorId, canvas, name) { for (var y = 0; y < height; y++) { if (name=='bg') canvas.drawImage(blockImage, 0, blockIcon * 32, 32, 32, x * 32, y * 32, 32, 32); - if (arr[y][x]>0 && arr[y][x]!=17) { + if (arr[y][x]>0) { var block = core.maps.initBlock(x, y, arr[y][x]); if (core.isset(block.event)) { var id = block.event.id, cls = block.event.cls; @@ -409,7 +414,12 @@ maps.prototype.drawBgFgMap = function (floorId, canvas, name) { else if (cls == 'tileset') { var offset = core.icons.getTilesetOffset(id); if (offset!=null) { - canvas.drawImage(core.material.images.tilesets[offset.image], 32*offset.x, 32*offset.y, 32, 32, 32*block.x, 32*block.y, 32, 32); + canvas.drawImage(core.material.images.tilesets[offset.image], 32*offset.x, 32*offset.y, 32, 32, 32*x, 32*y, 32, 32); + } + } + else if (arr[y][x]==17) { + if (core.isset(core.material.images.airwall)) { + canvas.drawImage(core.material.images.airwall, 32*x, 32*y); } } else @@ -724,6 +734,11 @@ maps.prototype.moveBlock = function(x,y,steps,time,keep,callback) { if (core.isset(callback)) callback(); return; } + // 空气墙;忽略事件 + else if (block.id==17) { + if (core.isset(callback)) callback(); + return; + } else { image = core.material.images[block.event.cls]; bx = 0; @@ -848,6 +863,11 @@ maps.prototype.jumpBlock = function(sx,sy,ex,ey,time,keep,callback) { if (core.isset(callback)) callback(); return; } + // 空气墙;忽略事件 + else if (block.id==17) { + if (core.isset(callback)) callback(); + return; + } else { image = core.material.images[block.event.cls]; bx = 0; @@ -955,6 +975,8 @@ maps.prototype.animateBlock = function (loc,type,time,callback) { else if (block.event.cls == 'autotile') { return; } + // 空气墙,忽略事件 + else if (block.id==17) return; else { image = core.material.images[block.event.cls]; bx = 0; diff --git a/libs/ui.js b/libs/ui.js index d728c1a1..47cd026e 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2056,14 +2056,17 @@ ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, cente tempCanvas.drawImage(core.material.images.tilesets[offset.image], 32*offset.x, 32*offset.y, 32, 32, 32*block.x, 32*block.y, 32, 32); } } - else { - if (block.event.id!='none' && block.id!=17) { - var blockIcon = core.material.icons[block.event.cls][block.event.id]; - var blockImage = core.material.images[block.event.cls]; - var height = block.event.height || 32; - tempCanvas.drawImage(blockImage, 0, blockIcon * height, 32, height, 32*block.x, 32*block.y + 32 - height, 32, height); + else if (block.id==17) { + if (core.isset(core.material.images.airwall)) { + tempCanvas.drawImage(core.material.images.airwall, 32*block.x, 32*block.y); } } + else if (block.event.id!='none') { + var blockIcon = core.material.icons[block.event.cls][block.event.id]; + var blockImage = core.material.images[block.event.cls]; + var height = block.event.height || 32; + tempCanvas.drawImage(blockImage, 0, blockIcon * height, 32, height, 32*block.x, 32*block.y + 32 - height, 32, height); + } } } // draw hero From 74b6f48a01d0fd9db941490a7076bf3a00d91561 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Thu, 27 Sep 2018 18:01:38 +0800 Subject: [PATCH 5/9] editor-airwall --- _server/editor.js | 22 +++++++++++++++++----- _server/editor_mode.js | 2 +- _server/vm.js | 6 ++++++ editor-mobile.html | 1 + editor.html | 1 + project/images/airwall.png | Bin 0 -> 19108 bytes 6 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 project/images/airwall.png diff --git a/_server/editor.js b/_server/editor.js index 3f8c17db..7ef50d6a 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -97,6 +97,12 @@ editor.prototype.idsInit = function (maps, icons) { var id = indexBlock.event.id; var indexId = indexBlock.id; var allCls = Object.keys(icons); + if(i==17){ + editor.ids.push({'idnum': 17, 'id': id, 'images': 'terrains'}); + point++; + editor.indexs[i].push(point); + continue; + } for (var j = 0; j < allCls.length; j++) { if (id in icons[allCls[j]]) { editor.ids.push({'idnum': indexId, 'id': id, 'images': allCls[j], 'y': icons[allCls[j]][id]}); @@ -332,9 +338,9 @@ editor.prototype.drawInitData = function (icons) { continue; } if (img == 'terrains') { - editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + images[img].width) / 32, images[img].height + 32] + editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + images[img].width) / 32, images[img].height + 32*2] sumWidth += images[img].width; - maxHeight = Math.max(maxHeight, images[img].height + 32); + maxHeight = Math.max(maxHeight, images[img].height + 32*2); continue; } editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + images[img].width) / 32, images[img].height]; @@ -360,7 +366,7 @@ editor.prototype.drawInitData = function (icons) { for (var ii = 0; ii < imgNames.length; ii++) { var img = imgNames[ii]; if (img == 'terrains') { - dc.drawImage(images[img], nowx, 32); + dc.drawImage(images[img], nowx, 32*2); nowx += images[img].width; continue; } @@ -820,9 +826,11 @@ editor.prototype.listen = function () { if (pos.x == 0 && pos.y == 0) { // editor.info={idnum:0, id:'empty','images':'清除块', 'y':0}; editor.info = 0; + } else if(pos.x == 0 && pos.y == 1){ + editor.info = editor.ids[editor.indexs[17]]; } else { if (hasOwnProp(autotiles, pos.images)) editor.info = {'images': pos.images, 'y': 0}; - else if (pos.images == 'terrains') editor.info = {'images': pos.images, 'y': pos.y - 1}; + else if (pos.images == 'terrains') editor.info = {'images': pos.images, 'y': pos.y - 2}; else if (core.tilesets.indexOf(pos.images)!=-1) editor.info = {'images': pos.images, 'y': pos.y, 'x': pos.x-editor.widthsX[spriter][1]}; else editor.info = {'images': pos.images, 'y': pos.y}; @@ -897,13 +905,17 @@ editor.prototype.listen = function () { //选中清除块 editor.info = 0; editor.pos=pos; + } else if (thisevent.idnum==17){ + editor.info = editor.ids[editor.indexs[17]]; + pos.y=1; + editor.pos=pos; } else { var ids=editor.indexs[thisevent.idnum]; ids=ids[0]?ids[0]:ids; editor.info=editor.ids[ids]; pos.x=editor.widthsX[thisevent.images][1]; pos.y=editor.info.y; - if(thisevent.images=='terrains')pos.y++; + if(thisevent.images=='terrains')pos.y+=2; ysize = thisevent.images.indexOf('48') === -1 ? 32 : 48; } setTimeout(function(){selectBox.isSelected = true;}); diff --git a/_server/editor_mode.js b/_server/editor_mode.js index ad0ba74f..9bbf0c0b 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -315,7 +315,7 @@ editor_mode = function (editor) { //editor.info=editor.ids[editor.indexs[201]]; if (!core.isset(editor.info)) return; - if (Object.keys(editor.info).length !== 0) editor_mode.info = editor.info;//避免editor.info被清空导致无法获得是物品还是怪物 + if (Object.keys(editor.info).length !== 0 && editor.info.idnum!=17) editor_mode.info = editor.info;//避免editor.info被清空导致无法获得是物品还是怪物 if (!core.isset(editor_mode.info.id)) { // document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML = ''; diff --git a/_server/vm.js b/_server/vm.js index afd49b90..6707dea0 100644 --- a/_server/vm.js +++ b/_server/vm.js @@ -241,6 +241,7 @@ var tip = new Vue({ isAutotile: false, isSelectedBlock: false, isClearBlock: false, + isAirwall: false, geneMapSuccess: false, timer: null, msgs: [ //分别编号1,2,3,4,5,6,7,8,9,10;奇数警告,偶数成功 @@ -264,12 +265,17 @@ var tip = new Vue({ infos: { handler: function (val, oldval) { this.isClearBlock = false; + this.isAirwall = false; if (typeof(val) != 'undefined') { if (val == 0) { this.isClearBlock = true; return; } if ('id' in val) { + if (val.idnum == 17) { + this.isAirwall = true; + return; + } this.hasId = true; } else { this.hasId = false; diff --git a/editor-mobile.html b/editor-mobile.html index 992e6053..75c4de36 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -234,6 +234,7 @@

当前选择为清除块,可擦除地图上块

+

当前选择为空气墙, 在编辑器中可视, 在游戏中隐藏的墙, 用来配合前景/背景的贴图

图块编号:{{ infos['idnum'] }}

图块ID:{{ infos['id'] }}

diff --git a/editor.html b/editor.html index 425a16f1..90c2716f 100644 --- a/editor.html +++ b/editor.html @@ -221,6 +221,7 @@

当前选择为清除块,可擦除地图上块

+

当前选择为空气墙, 在编辑器中可视, 在游戏中隐藏的墙, 用来配合前景/背景的贴图

图块编号:{{ infos['idnum'] }}

图块ID:{{ infos['id'] }}

diff --git a/project/images/airwall.png b/project/images/airwall.png new file mode 100644 index 0000000000000000000000000000000000000000..e1607d65b9531f76e1a06dc8217f124d15f5608c GIT binary patch literal 19108 zcmeI3&u`;I6vw9s5L8;R;)1jntSm?%aQrJjYAeZVX?AHPvQ*t7x+iuz9=Fyewz1t! z+S3Y79N_{t{saC24xG5{Ubz8hIItHkoXXhF59cMBR_elDo~0yy^PTtJ_%rjy&cR>p z-1+dz`n7dJ$d&D_?ymS%vd=3oi|^$0^l$O=YP5APA>{Qm`>g%uy*VPp{>$InPxpHt zIV>DhsT&^f>Sz#&-h{Mnj3UY&@KibAhknqmJpJ*fisHNN%BS_7-itQ*k-v2s^Sh^a z_SoqIX1kReo%Pnp5dj7~rOIf~4-#k8uHv#$2ga z>nhVtLuuMoqh4<|&G!{kH)@)0XojU4wo|J)x~`0mN@rc1wPM$EcDuL7>4ep;9HnXG zXxeZ%tPZVe7$0heZQGh|YNn}*9%^zDq;#YP$@L=0BuFVanDJW=#id+dcJ-<6%_e6q zQl_jNJ0JNg+%lzb%a=kiLoIQw&SuPM8peBJ*zXjpY-fT{+1$)mmGaJ~e&B|~^F;-nO$=m}!OoX2e%WK$;n#F1=Gfi7H48Eb-wkJ&5V2n3BYr{L3Bq{}4Nc3^+i+zvw zOMS9yaYeF*%M435sVc^7s;*vh)eTRW%?34_yyh|eV0tY}!YriP@)NOIPfDv;tmS-X zyURbHZ=DEzKi{Du8YeufzjkF(fYU8)x?^QNc^x~HWqVtPW#z%$mNwTq8`jiw?B*{{ z=fw~d@k{Qja}1AoASiJv%fb`yTt2b?AHV9N)4IeP^zp1b*5v$LT$L|auadM`2ZDh z0U&Y{amo1r6>$L|auadM`2ZDh0U&Y{amo1r6>$L|auadM`2ZDh0U&Y{amo1r6>$L| zauadM`2ZDh0U&Y{amo1r6>$L|auadM`2ZDh0U&Y{amo1r6>$L|auadM`2ZDh0U&Y{ zamo1r6>$L|auadM`2ZDh0U&Y{amo1r6>$L|auadM`2ZDh0U&Y{amo1r6>$L|auadM z`2ZDh0U&ZyifeuL5+@JDo0~)Nil!fb`>S}pQ(;@XJwi_3CgjnVg#2?Re*YlkSSRGq z`-C{(5%Na(&1XN~CgiHV-MzUtS|iHU-=D5Me*E~6@LzdYmi1_*D1;|Zo=Elc{9lj- z|35Sw01`j~YiDO-%a9zGt@HEzaSD(C5_s+eUOcZ(&%2*r*8jN^zyTluB!JHYxCW2_ g5?CYT?Ckq%Z@u)(Yx`eke-E~A-Rb`D!Tm4(1)>~GkpKVy literal 0 HcmV?d00001 From 21ab8a44509ef3b9491a70eafd58c413b3f856fa Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Thu, 27 Sep 2018 18:48:52 +0800 Subject: [PATCH 6/9] editor-airwall --- _server/editor.js | 12 ++++++++++++ editor-mobile.html | 2 ++ editor.html | 2 ++ 3 files changed, 16 insertions(+) diff --git a/_server/editor.js b/_server/editor.js index 7ef50d6a..07ed8fb8 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -366,6 +366,18 @@ editor.prototype.drawInitData = function (icons) { for (var ii = 0; ii < imgNames.length; ii++) { var img = imgNames[ii]; if (img == 'terrains') { + (function(image,dc,nowx){ + if (image.complete) { + dc.drawImage(image, nowx, 32); + core.material.images.airwall = image; + delete(editor.airwallImg); + } else image.onload = function () { + dc.drawImage(image, nowx, 32); + core.material.images.airwall = image; + delete(editor.airwallImg); + editor.updateMap(); + } + })(editor.airwallImg,dc,nowx); dc.drawImage(images[img], nowx, 32*2); nowx += images[img].width; continue; diff --git a/editor-mobile.html b/editor-mobile.html index 75c4de36..3f656e78 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -451,6 +451,8 @@ if (location.protocol.indexOf("http")!=0) { var useCompress = main.useCompress; main.useCompress = false; + editor.airwallImg = new Image(); + editor.airwallImg.src = './project/images/airwall.png'; main.init('editor', function () { editor.init(function () { editor.useCompress = useCompress; diff --git a/editor.html b/editor.html index 90c2716f..f3d9b16f 100644 --- a/editor.html +++ b/editor.html @@ -435,6 +435,8 @@ if (location.protocol.indexOf("http")!=0) {