Long Press
This commit is contained in:
parent
ebf42b3227
commit
6707e7eca0
@ -303,7 +303,7 @@ position为可选项,表示设置文字显示位置。只能为up(上),c
|
||||
|
||||
bold为可选项,如果设置则为true或false,表示正文是否使用粗体。 默认值:`false`
|
||||
|
||||
time为可选项,表示文字滚动的速度。若此项设置为0将直接全部显示,若大于0则会设置为相邻字符依次显示的时间间隔。 默认值:`50`
|
||||
time为可选项,表示文字添加的速度。若此项设置为0将直接全部显示,若大于0则会设置为相邻字符依次显示的时间间隔。 默认值:`0`
|
||||
|
||||
### tip:显示一段提示文字
|
||||
|
||||
|
||||
32
libs/core.js
32
libs/core.js
@ -17,12 +17,14 @@ function core() {
|
||||
this.timeout = {
|
||||
'getItemTipTimeout': null,
|
||||
'turnHeroTimeout': null,
|
||||
'onDownTimeout': null,
|
||||
}
|
||||
this.interval = {
|
||||
'heroMoveInterval': null,
|
||||
"tipAnimate": null,
|
||||
'openDoorAnimate': null,
|
||||
'animateInterval': null,
|
||||
'onDownInterval': null,
|
||||
}
|
||||
this.animateFrame = {
|
||||
'background': null,
|
||||
@ -132,7 +134,7 @@ function core() {
|
||||
"background": [0,0,0,0.85],
|
||||
"text": [255,255,255,1],
|
||||
"bold": false,
|
||||
"time": 50,
|
||||
"time": 0,
|
||||
},
|
||||
'curtainColor': null,
|
||||
'usingCenterFly':false,
|
||||
@ -772,8 +774,13 @@ core.prototype.clearStatus = function() {
|
||||
core.prototype.resetStatus = function(hero, hard, floorId, route, maps) {
|
||||
|
||||
// 停止各个Timeout和Interval
|
||||
for (var i in core.timeout) {
|
||||
clearTimeout(core.timeout[i]);
|
||||
core.timeout[i] = null;
|
||||
}
|
||||
for (var i in core.interval) {
|
||||
clearInterval(core.interval[i]);
|
||||
core.interval[i] = null;
|
||||
}
|
||||
|
||||
// 初始化status
|
||||
@ -1226,6 +1233,18 @@ core.prototype.ondown = function (x ,y) {
|
||||
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
|
||||
if (!core.status.played || core.status.lockControl) {
|
||||
core.onclick(x, y, []);
|
||||
if (core.timeout.onDownTimeout==null) {
|
||||
core.timeout.onDownTimeout = setTimeout(function () {
|
||||
if (core.interval.onDownInterval == null) {
|
||||
core.interval.onDownInterval = setInterval(function () {
|
||||
if (!core.events.longClick()) {
|
||||
clearInterval(core.interval.onDownInterval);
|
||||
core.interval.onDownInterval = null;
|
||||
}
|
||||
}, 40)
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1268,6 +1287,12 @@ core.prototype.onmove = function (x ,y) {
|
||||
////// 当点击(触摸)事件放开时 //////
|
||||
core.prototype.onup = function () {
|
||||
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
|
||||
|
||||
clearTimeout(core.timeout.onDownTimeout);
|
||||
core.timeout.onDownTimeout = null;
|
||||
clearInterval(core.interval.onDownInterval);
|
||||
core.interval.onDownInterval = null;
|
||||
|
||||
// core.status.holdingPath=0;
|
||||
if(core.status.stepPostfix.length>0){
|
||||
var stepPostfix = [];
|
||||
@ -1287,7 +1312,10 @@ core.prototype.onup = function () {
|
||||
|
||||
// 长按
|
||||
if (!core.status.lockControl && stepPostfix.length==0 && core.status.downTime!=null && new Date()-core.status.downTime>=1000) {
|
||||
core.events.longClick();
|
||||
core.waitHeroToStop(function () {
|
||||
// 绘制快捷键
|
||||
core.ui.drawKeyBoard();
|
||||
});
|
||||
}
|
||||
else {
|
||||
//posx,posy是寻路的目标点,stepPostfix是后续的移动
|
||||
|
||||
@ -1095,10 +1095,15 @@ events.prototype.afterLoadData = function(data) {
|
||||
|
||||
////// 长按 //////
|
||||
events.prototype.longClick = function () {
|
||||
core.waitHeroToStop(function () {
|
||||
// 绘制快捷键
|
||||
core.ui.drawKeyBoard();
|
||||
});
|
||||
if (core.status.event.id=='text') {
|
||||
core.drawText();
|
||||
return true;
|
||||
}
|
||||
if (core.status.event.id=='action' && core.status.event.data.type=='text') {
|
||||
this.doAction();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
////// 按下Ctrl键时(快捷跳过对话) //////
|
||||
|
||||
Loading…
Reference in New Issue
Block a user