commit
556c893bda
@ -1342,6 +1342,12 @@ core.loadMap(data, floorId)
|
|||||||
从data中读取楼层数据,并调用core.loadFloor()进行初始化。
|
从data中读取楼层数据,并调用core.loadFloor()进行初始化。
|
||||||
|
|
||||||
|
|
||||||
|
core.removeMaps(fromId, toId)
|
||||||
|
删除某个区域的地图。调用此函数后,这些楼层将不可飞,不可被浏览地图,也不计入存档。
|
||||||
|
fromId和toId为要删除的起终点楼层ID;toId也可以不填代表只删除某一层。
|
||||||
|
此函数适用于高层塔的砍层,例如每100层一个区域且互相独立,不可再返回的情况。
|
||||||
|
|
||||||
|
|
||||||
core.resizeMap(floorId)
|
core.resizeMap(floorId)
|
||||||
根据某层楼的地图大小来调整大地图的画布大小。floorId可为null表示当前层。
|
根据某层楼的地图大小来调整大地图的画布大小。floorId可为null表示当前层。
|
||||||
|
|
||||||
|
|||||||
@ -64,6 +64,9 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏!
|
|||||||
* [x] 编辑器支持连续Ctrl+Z的撤销,Ctrl+Y的重做
|
* [x] 编辑器支持连续Ctrl+Z的撤销,Ctrl+Y的重做
|
||||||
* [x] 新增tileset右键绑定宽高,以替代贴图模式
|
* [x] 新增tileset右键绑定宽高,以替代贴图模式
|
||||||
* [x] 多重自动存档,可以连续A键读档
|
* [x] 多重自动存档,可以连续A键读档
|
||||||
|
* [x] 高层塔分区域支持
|
||||||
|
* [x] 自绘状态栏点击事件
|
||||||
|
* [x] 绘制的锁定模式
|
||||||
* [x] 等待用户操作增设分歧选项
|
* [x] 等待用户操作增设分歧选项
|
||||||
* [x] 增设压缩模式,会对图片等进行zip压缩
|
* [x] 增设压缩模式,会对图片等进行zip压缩
|
||||||
* [x] 追加素材现在可以同时进行自动注册
|
* [x] 追加素材现在可以同时进行自动注册
|
||||||
|
|||||||
@ -1341,6 +1341,12 @@ core.loadMap(data, floorId)
|
|||||||
从data中读取楼层数据,并调用core.loadFloor()进行初始化。
|
从data中读取楼层数据,并调用core.loadFloor()进行初始化。
|
||||||
|
|
||||||
|
|
||||||
|
core.removeMaps(fromId, toId)
|
||||||
|
删除某个区域的地图。调用此函数后,这些楼层将不可飞,不可被浏览地图,也不计入存档。
|
||||||
|
fromId和toId为要删除的起终点楼层ID;toId也可以不填代表只删除某一层。
|
||||||
|
此函数适用于高层塔的砍层,例如每100层一个区域且互相独立,不可再返回的情况。
|
||||||
|
|
||||||
|
|
||||||
core.resizeMap(floorId)
|
core.resizeMap(floorId)
|
||||||
根据某层楼的地图大小来调整大地图的画布大小。floorId可为null表示当前层。
|
根据某层楼的地图大小来调整大地图的画布大小。floorId可为null表示当前层。
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,7 @@ function editor() {
|
|||||||
lastUsedDiv: document.getElementById('lastUsedDiv'),
|
lastUsedDiv: document.getElementById('lastUsedDiv'),
|
||||||
lastUsed: document.getElementById('lastUsed'),
|
lastUsed: document.getElementById('lastUsed'),
|
||||||
lastUsedCtx: document.getElementById('lastUsed').getContext('2d'),
|
lastUsedCtx: document.getElementById('lastUsed').getContext('2d'),
|
||||||
|
lockMode: document.getElementById('lockMode'),
|
||||||
};
|
};
|
||||||
|
|
||||||
this.uivalues={
|
this.uivalues={
|
||||||
@ -98,6 +99,7 @@ function editor() {
|
|||||||
|
|
||||||
// tile
|
// tile
|
||||||
tileSize: [1,1],
|
tileSize: [1,1],
|
||||||
|
lockMode: false,
|
||||||
|
|
||||||
// 最近使用的图块
|
// 最近使用的图块
|
||||||
lastUsed: [],
|
lastUsed: [],
|
||||||
@ -405,20 +407,22 @@ editor.prototype.updateLastUsedMap = function () {
|
|||||||
ctx.strokeStyle = 'rgba(255,128,0,0.85)';
|
ctx.strokeStyle = 'rgba(255,128,0,0.85)';
|
||||||
ctx.lineWidth = 4;
|
ctx.lineWidth = 4;
|
||||||
for (var i = 0; i < editor.uivalues.lastUsed.length; ++i) {
|
for (var i = 0; i < editor.uivalues.lastUsed.length; ++i) {
|
||||||
var x = i % core.__SIZE__, y = parseInt(i / core.__SIZE__);
|
try {
|
||||||
var info = editor.uivalues.lastUsed[i];
|
var x = i % core.__SIZE__, y = parseInt(i / core.__SIZE__);
|
||||||
if (!info || !info.images) continue;
|
var info = editor.uivalues.lastUsed[i];
|
||||||
if (info.isTile) {
|
if (!info || !info.images) continue;
|
||||||
ctx.drawImage(core.material.images.tilesets[info.images], 32 * info.x, 32 * info.y, 32, 32, x*32, y*32, 32, 32);
|
if (info.isTile && core.material.images.tilesets[info.images]) {
|
||||||
} else if (info.images == 'autotile') {
|
ctx.drawImage(core.material.images.tilesets[info.images], 32 * info.x, 32 * info.y, 32, 32, x*32, y*32, 32, 32);
|
||||||
ctx.drawImage(core.material.images.autotile[info.id], 0, 0, 32, 32, x * 32, y * 32, 32, 32);
|
} else if (info.images == 'autotile' && core.material.images.autotile[info.id]) {
|
||||||
} else {
|
ctx.drawImage(core.material.images.autotile[info.id], 0, 0, 32, 32, x * 32, y * 32, 32, 32);
|
||||||
var per_height = info.images.endsWith('48') ? 48 : 32;
|
} else {
|
||||||
ctx.drawImage(core.material.images[info.images], 0, info.y * per_height, 32, per_height, x * 32, y * 32, 32, 32);
|
var per_height = info.images.endsWith('48') ? 48 : 32;
|
||||||
}
|
ctx.drawImage(core.material.images[info.images], 0, info.y * per_height, 32, per_height, x * 32, y * 32, 32, 32);
|
||||||
if (selectBox.isSelected() && editor.info.id == info.id) {
|
}
|
||||||
ctx.strokeRect(32 * x + 2, 32 * y + 2, 28, 28);
|
if (selectBox.isSelected() && editor.info.id == info.id) {
|
||||||
}
|
ctx.strokeRect(32 * x + 2, 32 * y + 2, 28, 28);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,7 @@ editor_listen_wrapper = function (editor) {
|
|||||||
editor.dom.clearLoc.onmousedown = editor.uifunctions.clearLoc_click
|
editor.dom.clearLoc.onmousedown = editor.uifunctions.clearLoc_click
|
||||||
|
|
||||||
editor.dom.lastUsed.onmousedown = editor.uifunctions.lastUsed_click;
|
editor.dom.lastUsed.onmousedown = editor.uifunctions.lastUsed_click;
|
||||||
|
editor.dom.lockMode.onchange = editor.uifunctions.lockMode_onchange;
|
||||||
|
|
||||||
editor.dom.brushMod.onchange = editor.uifunctions.brushMod_onchange
|
editor.dom.brushMod.onchange = editor.uifunctions.brushMod_onchange
|
||||||
if (editor.dom.brushMod2) editor.dom.brushMod2.onchange = editor.uifunctions.brushMod2_onchange;
|
if (editor.dom.brushMod2) editor.dom.brushMod2.onchange = editor.uifunctions.brushMod2_onchange;
|
||||||
|
|||||||
@ -570,6 +570,16 @@ editor_mappanel_wrapper = function (editor) {
|
|||||||
editor.clearPos(true);
|
editor.clearPos(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* editor.dom.lockMode.onchange
|
||||||
|
* 点击【】
|
||||||
|
*/
|
||||||
|
editor.uifunctions.lockMode_onchange = function () {
|
||||||
|
tip.msgs[11] = String('锁定模式开启下将不再点击空白处自动保存,请谨慎操作。');
|
||||||
|
tip.whichShow(12);
|
||||||
|
editor.uivalues.lockMode = editor.dom.lockMode.checked;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editor.dom.brushMod.onchange
|
* editor.dom.brushMod.onchange
|
||||||
* 切换画笔模式
|
* 切换画笔模式
|
||||||
@ -591,7 +601,10 @@ editor_mappanel_wrapper = function (editor) {
|
|||||||
* 切换画笔模式
|
* 切换画笔模式
|
||||||
*/
|
*/
|
||||||
editor.uifunctions.brushMod3_onchange = function () {
|
editor.uifunctions.brushMod3_onchange = function () {
|
||||||
alert("从V2.6.6开始,tileset贴图模式已被废弃。\n请右键额外素材,并输入所需要绘制的宽高,然后单击地图以绘制一个区域。");
|
if (!core.getLocalStorage('alertTileMode') &&
|
||||||
|
!confirm("从V2.6.6开始,tileset贴图模式已被废弃。\n请右键额外素材,并输入所需要绘制的宽高,然后单击地图以绘制一个区域。\n\n点取消将不再显示此提示。")) {
|
||||||
|
core.setLocalStorage('alertTileMode', true);
|
||||||
|
}
|
||||||
// tip.showHelp(5)
|
// tip.showHelp(5)
|
||||||
tip.isSelectedBlock(false)
|
tip.isSelectedBlock(false)
|
||||||
tip.msgs[11] = String('tileset贴图模式下可以按选中tileset素材,并在地图上拖动来一次绘制一个区域');
|
tip.msgs[11] = String('tileset贴图模式下可以按选中tileset素材,并在地图上拖动来一次绘制一个区域');
|
||||||
|
|||||||
@ -48,7 +48,7 @@ editor_ui_wrapper = function (editor) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unselect) {
|
if (unselect && !editor.uivalues.lockMode) {
|
||||||
if (clickpath.indexOf('eui') === -1 && clickpath.indexOf('lastUsed') === -1) {
|
if (clickpath.indexOf('eui') === -1 && clickpath.indexOf('lastUsed') === -1) {
|
||||||
if (selectBox.isSelected()) {
|
if (selectBox.isSelected()) {
|
||||||
editor_mode.onmode('');
|
editor_mode.onmode('');
|
||||||
|
|||||||
@ -139,6 +139,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
"_type": "textarea",
|
"_type": "textarea",
|
||||||
"_lint": true,
|
"_lint": true,
|
||||||
"_data": "按键处理"
|
"_data": "按键处理"
|
||||||
|
},
|
||||||
|
"onStatusBarClick": {
|
||||||
|
"_leaf": true,
|
||||||
|
"_type": "textarea",
|
||||||
|
"_lint": true,
|
||||||
|
"_data": "状态栏点击事件,仅在开启自绘状态栏时生效"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -374,6 +374,7 @@
|
|||||||
<option value="commonevent">公共事件</option>
|
<option value="commonevent">公共事件</option>
|
||||||
<option value="plugins">插件编写</option>
|
<option value="plugins">插件编写</option>
|
||||||
</select>
|
</select>
|
||||||
|
<span style="font-size: 12px"><input type="checkbox" id="lockMode"/>锁定模式</span>
|
||||||
<select id="brushMod" style="clear:right">
|
<select id="brushMod" style="clear:right">
|
||||||
<option value="line">画线</option>
|
<option value="line">画线</option>
|
||||||
<option value="rectangle">画矩形</option>
|
<option value="rectangle">画矩形</option>
|
||||||
|
|||||||
@ -333,6 +333,7 @@
|
|||||||
<option value="commonevent">公共事件</option>
|
<option value="commonevent">公共事件</option>
|
||||||
<option value="plugins">插件编写</option>
|
<option value="plugins">插件编写</option>
|
||||||
</select>
|
</select>
|
||||||
|
<span style="font-size: 12px"><input type="checkbox" id="lockMode"/>锁定模式</span>
|
||||||
<br/>
|
<br/>
|
||||||
<span style="font-size: 12px;">
|
<span style="font-size: 12px;">
|
||||||
<input type="radio" id="brushMod" name="brushMod" value="line" checked="checked" />画线
|
<input type="radio" id="brushMod" name="brushMod" value="line" checked="checked" />画线
|
||||||
|
|||||||
@ -59,6 +59,8 @@ actions.prototype._init = function () {
|
|||||||
// --- longClick注册
|
// --- longClick注册
|
||||||
this.registerAction('longClick', '_sys_longClick_lockControl', this._sys_longClick_lockControl, 50);
|
this.registerAction('longClick', '_sys_longClick_lockControl', this._sys_longClick_lockControl, 50);
|
||||||
this.registerAction('longClick', '_sys_longClick', this._sys_longClick, 0);
|
this.registerAction('longClick', '_sys_longClick', this._sys_longClick, 0);
|
||||||
|
// --- onStatusBarClick注册
|
||||||
|
this.registerAction('onStatusBarClick', '_sys_onStatusBarClick', this._sys_onStatusBarClick, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,7 +614,7 @@ actions.prototype._getClickLoc = function (x, y) {
|
|||||||
////// 具体点击屏幕上(x,y)点时,执行的操作 //////
|
////// 具体点击屏幕上(x,y)点时,执行的操作 //////
|
||||||
actions.prototype.onclick = function (x, y, stepPostfix) {
|
actions.prototype.onclick = function (x, y, stepPostfix) {
|
||||||
// console.log("Click: (" + x + "," + y + ")");
|
// console.log("Click: (" + x + "," + y + ")");
|
||||||
this.doRegisteredAction('onclick', x, y, stepPostfix || []);
|
return this.doRegisteredAction('onclick', x, y, stepPostfix || []);
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.prototype._sys_onclick_lockControl = function (x, y) {
|
actions.prototype._sys_onclick_lockControl = function (x, y) {
|
||||||
@ -844,6 +846,19 @@ actions.prototype._sys_longClick = function (x, y, fromEvent) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actions.prototype.onStatusBarClick = function (e) {
|
||||||
|
if (!core.isPlaying()) return false;
|
||||||
|
var left = core.dom.gameGroup.offsetLeft + 3;
|
||||||
|
var top = core.dom.gameGroup.offsetTop + 3;
|
||||||
|
var px = parseInt((e.clientX - left) / core.domStyle.scale), py = parseInt((e.clientY - top) / core.domStyle.scale);
|
||||||
|
return this.doRegisteredAction('onStatusBarClick', px, py);
|
||||||
|
}
|
||||||
|
|
||||||
|
actions.prototype._sys_onStatusBarClick = function (px, py) {
|
||||||
|
if (this.actionsdata.onStatusBarClick)
|
||||||
|
return this.actionsdata.onStatusBarClick(px, py);
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////// 在某个界面时的按键点击效果 ///////////////////
|
/////////////////// 在某个界面时的按键点击效果 ///////////////////
|
||||||
|
|
||||||
// 数字键快速选择选项
|
// 数字键快速选择选项
|
||||||
|
|||||||
@ -207,9 +207,7 @@ loader.prototype._loadAnimates = function () {
|
|||||||
core.loader._loadAnimate(t, animates[name]);
|
core.loader._loadAnimate(t, animates[name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, null, true, function (percentage) {
|
}, null, true);
|
||||||
core.loader._setStartProgressVal(percentage * 100);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
core.animates.forEach(function (t) {
|
core.animates.forEach(function (t) {
|
||||||
core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) {
|
core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) {
|
||||||
@ -284,8 +282,6 @@ loader.prototype._loadMusic = function () {
|
|||||||
core.loader._loadOneSound_decodeData(name, data[name]);
|
core.loader._loadOneSound_decodeData(name, data[name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, null, false, function (percentage) {
|
|
||||||
core.loader._setStartProgressVal(percentage * 100);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
core.sounds.forEach(function (t) {
|
core.sounds.forEach(function (t) {
|
||||||
|
|||||||
22
libs/maps.js
22
libs/maps.js
@ -258,6 +258,11 @@ maps.prototype.saveMap = function (floorId) {
|
|||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
// 砍层状态:直接返回
|
||||||
|
if (main.mode == 'play' && (flags.__removed__ || []).indexOf(floorId) >= 0) {
|
||||||
|
return { canFlyTo: false, cannotViewMap: true };
|
||||||
|
}
|
||||||
|
|
||||||
var map = maps[floorId], floor = core.floors[floorId];
|
var map = maps[floorId], floor = core.floors[floorId];
|
||||||
var blocks = this._getMapArrayFromBlocks(map.blocks, floor.width, floor.height, true);
|
var blocks = this._getMapArrayFromBlocks(map.blocks, floor.width, floor.height, true);
|
||||||
if (main.mode == 'editor') return blocks;
|
if (main.mode == 'editor') return blocks;
|
||||||
@ -293,6 +298,23 @@ maps.prototype.loadMap = function (data, floorId) {
|
|||||||
return this.loadFloor(floorId, data[floorId]);
|
return this.loadFloor(floorId, data[floorId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// 删除地图,不计入存档 //////
|
||||||
|
maps.prototype.removeMaps = function (fromId, toId) {
|
||||||
|
if (!core.isPlaying()) return;
|
||||||
|
toId = toId || fromId;
|
||||||
|
var fromIndex = core.floorIds.indexOf(fromId),
|
||||||
|
toIndex = core.floorIds.indexOf(toId);
|
||||||
|
if (toIndex < 0) toIndex = core.floorIds.length - 1;
|
||||||
|
flags.__removed__ = flags.__removed__ || [];
|
||||||
|
for (var i = fromIndex; i <= toIndex; ++i) {
|
||||||
|
var floorId = core.floorIds[i];
|
||||||
|
delete flags.__visited__[floorId];
|
||||||
|
flags.__removed__.push(floorId);
|
||||||
|
core.status.maps[floorId].canFlyTo = false;
|
||||||
|
core.status.maps[floorId].cannotViewMap = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////// 更改地图画布的尺寸
|
////// 更改地图画布的尺寸
|
||||||
maps.prototype.resizeMap = function (floorId) {
|
maps.prototype.resizeMap = function (floorId) {
|
||||||
floorId = floorId || core.status.floorId;
|
floorId = floorId || core.status.floorId;
|
||||||
|
|||||||
9
main.js
9
main.js
@ -518,6 +518,15 @@ main.dom.data.ontouchend = function (e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main.dom.statusCanvas.onclick = function (e) {
|
||||||
|
try {
|
||||||
|
e.preventDefault();
|
||||||
|
main.core.onStatusBarClick(e);
|
||||||
|
} catch (e) {
|
||||||
|
main.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////// 点击状态栏中的怪物手册时 //////
|
////// 点击状态栏中的怪物手册时 //////
|
||||||
main.statusBar.image.book.onclick = function (e) {
|
main.statusBar.image.book.onclick = function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|||||||
@ -933,6 +933,23 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
"onStatusBarClick": function (px, py) {
|
||||||
|
// 点击状态栏时触发的事件,仅在自绘状态栏开启时生效
|
||||||
|
// px和py为点击的像素坐标
|
||||||
|
//
|
||||||
|
// 横屏模式下状态栏的画布大小是 129*416
|
||||||
|
// 竖屏模式下状态栏的画布大小是 416*(32*rows+9) 其中rows为状态栏行数,即全塔属性中statusCanvasRowsOnMobile值
|
||||||
|
// 可以使用 core.domStyle.isVertical 来判定当前是否是竖屏模式
|
||||||
|
|
||||||
|
// 如果正在执行事件,则忽略
|
||||||
|
if (core.status.lockControl) return;
|
||||||
|
// 如果当前正在行走,则忽略;也可以使用 core.waitHeroToStop(callback) 来停止行走再回调执行脚本
|
||||||
|
if (core.isMoving()) return;
|
||||||
|
|
||||||
|
// 判定px和py来执行自己的脚本内容.... 注意横竖屏
|
||||||
|
// 这里是直接打出点击坐标的例子。
|
||||||
|
// console.log("onStatusBarClick:", px, py);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"control": {
|
"control": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user