onStatusBarClick
This commit is contained in:
parent
347af83355
commit
ee025ad7b0
@ -139,6 +139,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "按键处理"
|
||||
},
|
||||
"onStatusBarClick": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "状态栏点击事件,仅在开启自绘状态栏时生效"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -59,6 +59,8 @@ actions.prototype._init = function () {
|
||||
// --- longClick注册
|
||||
this.registerAction('longClick', '_sys_longClick_lockControl', this._sys_longClick_lockControl, 50);
|
||||
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)点时,执行的操作 //////
|
||||
actions.prototype.onclick = function (x, y, stepPostfix) {
|
||||
// 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) {
|
||||
@ -844,6 +846,21 @@ actions.prototype._sys_longClick = function (x, y, fromEvent) {
|
||||
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 (!core.status.played) return true;
|
||||
if (this.actionsdata.onStatusBarClick) {
|
||||
this.actionsdata.onStatusBarClick(px, py);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////// 在某个界面时的按键点击效果 ///////////////////
|
||||
|
||||
// 数字键快速选择选项
|
||||
|
||||
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) {
|
||||
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.event.id != null) return;
|
||||
// 如果当前正在行走,则忽略;也可以使用 core.waitHeroToStop(callback) 来停止行走再回调执行脚本
|
||||
if (core.isMoving()) return;
|
||||
|
||||
// 判定px和py来执行自己的脚本内容.... 注意横竖屏
|
||||
// 这里是直接打出点击坐标的例子。
|
||||
// console.log("onStatusBarClick:", px, py);
|
||||
}
|
||||
},
|
||||
"control": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user