48 in bg/fg

This commit is contained in:
oc 2019-02-20 21:30:30 +08:00
parent 15c889146d
commit f98c85442f
2 changed files with 20 additions and 19 deletions

View File

@ -797,25 +797,21 @@ editor.prototype.listen = function () {
currDrawData.info = JSON.parse(JSON.stringify(editor.info));
reDo = null;
// console.log(stepPostfix);
if (editor.layerMod!='map' && editor.info.images && editor.info.images.indexOf('48')!==-1){
printe('前景/背景不支持48的图块');
} else {
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]];
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;
}
} else {
for (var ii = 0; ii < stepPostfix.length; ii++)
editor[editor.layerMod][stepPostfix[ii].y][stepPostfix[ii].x] = editor.info;
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();

View File

@ -432,11 +432,16 @@ maps.prototype.drawBlock = function (block, animate, dx, dy) {
if (!blockInfo.isTileset) x = (animate||0)%(block.event.animate||1);
if (core.isset(block.name)) {
core.clearMap(block.name, block.x * 32, block.y * 32, 32, 32);
core.clearMap(block.name, block.x * 32, block.y * 32 + 32 - height, 32, height);
if (block.name == 'bg') {
if (height>32) {
core.clearMap(block.name, block.x * 32, block.y * 32 - 32, 32, 32);
core.drawImage('bg', core.material.groundCanvas.canvas, block.x * 32, block.y * 32 - 32);
}
core.drawImage('bg', core.material.groundCanvas.canvas, block.x * 32, block.y * 32);
}
core.drawImage(block.name, image, x * 32, y * 32, 32, 32, block.x * 32, block.y * 32, 32, 32);
core.drawImage(block.name, image, x * 32, y * height, 32, height,
block.x * 32, block.y * 32 + 32 - height, 32, height);
return;
}