cursor follow mouse

This commit is contained in:
ckcz123 2019-12-29 21:43:42 +08:00
parent 4d0ad198a4
commit 1b4f947550
3 changed files with 51 additions and 2 deletions

View File

@ -42,6 +42,7 @@ actions.prototype._init = function () {
// --- onmove注册
this.registerAction('onmove', '_sys_checkReplay', this._sys_checkReplay, 100);
this.registerAction('onmove', '_sys_onmove_paint', this._sys_onmove_paint, 50);
this.registerAction('onmove', '_sys_onmove_choices', this._sys_onmove_choices, 30);
this.registerAction('onmove', '_sys_onmove', this._sys_onmove, 0);
// --- onup注册
this.registerAction('onup', '_sys_checkReplay', this._sys_checkReplay, 100);
@ -486,6 +487,29 @@ actions.prototype._sys_onmove_paint = function (x, y, px, py) {
}
}
actions.prototype._sys_onmove_choices = function (x, y) {
if (!core.status.lockControl) return false;
switch (core.status.event.id) {
case 'action':
if (core.status.event.id != 'choices') break;
case 'selectShop':
case 'switchs':
case 'settings':
case 'syncSave':
case 'syncSelect':
case 'localSaveSelect':
case 'storageRemove':
case 'replay':
case 'gameInfo':
this._onMoveChoices(x, y);
return true;
default:
break;
}
return false;
}
actions.prototype._sys_onmove = function (x, y) {
if ((core.status.stepPostfix || []).length > 0) {
var pos = {'x': x, 'y': y};
@ -852,6 +876,21 @@ actions.prototype._keyDownChoices = function (keycode) {
}
}
// 移动光标
actions.prototype._onMoveChoices = function (x, y) {
if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return;
var choices = core.status.event.ui.choices;
var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0);
if (y >= topIndex && y < topIndex + choices.length) {
var selection = y - topIndex;
if (selection == core.status.event.selection) return;
core.status.event.selection = selection;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
////// 点击中心对称飞行器时
actions.prototype._clickCenterFly = function (x, y) {
var posX = core.status.event.data.posX, posY = core.status.event.data.posY;

View File

@ -98,7 +98,7 @@ maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) {
var block = {'x': x, 'y': y, 'id': id};
if (disable != null) block.disable = disable;
if (id == 17) block.event = {"cls": "terrains", "id": "airwall", "noPass": true};
if (id == 17) block.event = {"cls": "terrains", "id": "airwall", "noPass": true, "cannotIn":["up", "down", "left", "right"]};
else if (id in this.blocksInfo) block.event = JSON.parse(JSON.stringify(this.blocksInfo[id]));
else if (core.icons.getTilesetOffset(id)) block.event = {"cls": "tileset", "id": "X" + id, "noPass": true};
else block.event = {'cls': 'terrains', 'id': 'none', 'noPass': false};

12
main.js
View File

@ -426,7 +426,17 @@ main.dom.body.onkeyup = function(e) {
(main.core.isPlaying() || main.core.status.lockControl))
main.core.onkeyUp(e);
} catch (ee) { main.log(ee); }
}
};
[main.dom.startButtons, main.dom.levelChooseButtons].forEach(function (dom) {
dom.onmousemove = function (e) {
for (var i = 0; i < dom.children.length; ++i) {
if (dom.children[i] == e.target && i != (main.selectedButton || 0)) {
main.selectButton(i);
}
}
}
});
////// 开始选择时 //////
main.dom.body.onselectstart = function () {