Merge pull request #252 from ckcz123/v2.0

V2.5
This commit is contained in:
Zhang Chen 2018-11-01 00:32:30 +08:00 committed by GitHub
commit 1c7e95239a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 44 deletions

View File

@ -581,8 +581,11 @@ editor_mode = function (editor) {
editor_mode.appendPic.height = image.height;
if (selectAppend.value == 'autotile') {
sprite.style.width = (sprite.width = image.width) / ratio + 'px';
sprite.style.height = (sprite.height = image.height) / ratio + 'px';
for (var ii = 0; ii < 3; ii++) {
var newsprite = appendPicCanvas.children[ii];
newsprite.style.width = (newsprite.width = image.width) / ratio + 'px';
newsprite.style.height = (newsprite.height = image.height) / ratio + 'px';
}
sprite_ctx.clearRect(0, 0, sprite.width, sprite.height);
sprite_ctx.drawImage(image, 0, 0);
}
@ -804,17 +807,12 @@ editor_mode = function (editor) {
appendConfirm.onclick = function () {
var confirmAutotile = function () {
if (sprite.width != 96 || sprite.height != 128) {
if (sprite.height==128 && sprite.width%96==0) {
printe("这里只能导入单帧的自动元件,多帧的动画请先导入单帧自动元件再同名替换素材即可。");
}
else {
var image = editor_mode.appendPic.img;
if (image.width % 96 !=0 || image.height != 128) {
printe("不合法的Autotile图片");
}
return;
}
var imgData = source_ctx.getImageData(0,0,sprite.width,sprite.height);
var imgData = source_ctx.getImageData(0,0,image.width,image.height);
sprite_ctx.putImageData(imgData, 0, 0);
var imgbase64 = sprite.toDataURL().split(',')[1];

View File

@ -372,18 +372,10 @@ actions.prototype.onmove = function (loc) {
}
////// 当点击(触摸)事件放开时 //////
actions.prototype.onup = function (loc) {
actions.prototype.onup = function () {
if (core.isset(core.status.replay)&&core.status.replay.replaying
&&core.status.event.id!='save'&&(core.status.event.id||"").indexOf('book')!=0&&core.status.event.id!='viewMaps') return;
// 画板
if (core.status.played && (core.status.event||{}).id=='paint') {
this.onupPaint(loc.x, loc.y)
return;
}
var x = parseInt(loc.x / loc.size), y = parseInt(loc.y / loc.size);
clearTimeout(core.timeout.onDownTimeout);
core.timeout.onDownTimeout = null;
clearInterval(core.interval.onDownInterval);
@ -2452,18 +2444,7 @@ actions.prototype.onmovePaint = function (x, y) {
core.status.event.data.y = y;
}
actions.prototype.onupPaint = function (x,y) {
x+=core.bigmap.offsetX;
y+=core.bigmap.offsetY;
if (core.status.event.data.erase) {
core.clearMap('route', x-5, y-5, 10, 10);
}
else if (core.status.event.data.x!=null) {
var midx = (core.status.event.data.x+x)/2, midy = (core.status.event.data.y+y)/2;
core.canvas.route.quadraticCurveTo(midx, midy, x, y);
core.canvas.route.stroke();
}
actions.prototype.onupPaint = function () {
core.status.event.data.x = null;
core.status.event.data.y = null;
// 保存

View File

@ -407,8 +407,8 @@ core.prototype.onmove = function (loc) {
}
////// 当点击(触摸)事件放开时 //////
core.prototype.onup = function (loc) {
return core.actions.onup(loc);
core.prototype.onup = function () {
return core.actions.onup();
}
////// 获得点击事件相对左上角的坐标0到12之间 //////

View File

@ -836,7 +836,7 @@ ui.prototype.drawSettings = function () {
core.status.event.id = 'settings';
this.drawChoices(null, [
"系统设置", "快捷商店", "浏览地图", "打开画板", "同步存档", "返回标题", "数据统计", "操作帮助", "关于本塔", "返回游戏"
"系统设置", "快捷商店", "浏览地图", "绘图模式", "同步存档", "返回标题", "数据统计", "操作帮助", "关于本塔", "返回游戏"
]);
}

12
main.js
View File

@ -344,12 +344,9 @@ main.dom.data.onmousemove = function (e) {
}
////// 鼠标放开时 //////
main.dom.data.onmouseup = function (e) {
main.dom.data.onmouseup = function () {
try {
e.stopPropagation();
var loc = main.core.getClickLoc(e.clientX, e.clientY);
if (loc == null) return;
main.core.onup(loc);
main.core.onup();
}catch (e) {}
}
@ -386,10 +383,7 @@ main.dom.data.ontouchmove = function (e) {
////// 手指离开触摸屏时 //////
main.dom.data.ontouchend = function () {
try {
e.preventDefault();
var loc = main.core.getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
if (loc == null) return;
main.core.onup(loc);
main.core.onup();
} catch (e) {
}
}