type:wait context
This commit is contained in:
parent
1216ae7d96
commit
bd59bea013
@ -1988,18 +1988,56 @@ return code;
|
||||
|
||||
|
||||
wait_s
|
||||
: '等待用户操作并获得按键或点击信息'
|
||||
: '等待用户操作并获得按键或点击信息' BGNL? Newline waitContext* BEND Newline
|
||||
|
||||
|
||||
/* wait_s
|
||||
tooltip : wait: 等待用户操作并获得按键或点击信息(具体用法看文档)
|
||||
tooltip : wait: 等待用户操作并获得按键或点击信息
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=wait%EF%BC%9A%E7%AD%89%E5%BE%85%E7%94%A8%E6%88%B7%E6%93%8D%E4%BD%9C
|
||||
colour : this.soundColor
|
||||
var code = '{"type": "wait"},\n';
|
||||
waitContext_0 = waitContext_0 ? (', "data": [\n' + waitContext_0 + ']') : '';
|
||||
var code = '{"type": "wait"' + waitContext_0 + '},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
|
||||
waitContext
|
||||
: waitContext_1
|
||||
| waitContext_2
|
||||
| waitContext_empty;
|
||||
|
||||
|
||||
waitContext_1
|
||||
: '按键的场合' '键值' Int BGNL? Newline action+ BEND Newline
|
||||
|
||||
/* waitContext_1
|
||||
tooltip : wait: 等待用户操作并获得按键或点击信息
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=wait%EF%BC%9A%E7%AD%89%E5%BE%85%E7%94%A8%E6%88%B7%E6%93%8D%E4%BD%9C
|
||||
colour : this.subColor
|
||||
var code = '{"case": "keyboard", "keycode": ' + Int_0 + ', "action": [\n' + action_0 + ']},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
|
||||
waitContext_2
|
||||
: '点击的场合' '像素x范围' Int '~' Int '; y范围' Int '~' Int BGNL? Newline action+ BEND Newline
|
||||
|
||||
/* waitContext_2
|
||||
tooltip : wait: 等待用户操作并获得按键或点击信息
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=wait%EF%BC%9A%E7%AD%89%E5%BE%85%E7%94%A8%E6%88%B7%E6%93%8D%E4%BD%9C
|
||||
default : [0,32,0,32]
|
||||
colour : this.subColor
|
||||
var code = '{"case": "mouse", "px": [' + Int_0 + ',' + Int_1 + '], "py": [' + Int_2 + ',' + Int_3 + '], "action": [\n' + action_0 + ']},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
waitContext_empty : Newline
|
||||
|
||||
/* waitContext_empty
|
||||
return '';
|
||||
*/;
|
||||
|
||||
|
||||
waitAsync_s
|
||||
: '等待所有异步事件执行完毕'
|
||||
|
||||
@ -3547,8 +3585,22 @@ ActionParser.prototype.parseAction = function() {
|
||||
data.time||0,data.noSkip||false,this.next]);
|
||||
break;
|
||||
case "wait": // 等待用户操作
|
||||
var case_waitList = null;
|
||||
if (data.data) {
|
||||
for(var ii=data.data.length-1,caseNow;caseNow=data.data[ii];ii--) {
|
||||
if (caseNow["case"] == "keyboard") {
|
||||
case_waitList = MotaActionBlocks['waitContext_1'].xmlText([
|
||||
caseNow.keycode || 0, this.insertActionList(caseNow.action), case_waitList
|
||||
]);
|
||||
} else if (caseNow["case"] == "mouse") {
|
||||
case_waitList = MotaActionBlocks['waitContext_2'].xmlText([
|
||||
caseNow.px[0], caseNow.px[1], caseNow.py[0], caseNow.py[1], this.insertActionList(caseNow.action), case_waitList
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.next = MotaActionBlocks['wait_s'].xmlText([
|
||||
this.next]);
|
||||
case_waitList, this.next]);
|
||||
break;
|
||||
case "waitAsync": // 等待所有异步事件执行完毕
|
||||
this.next = MotaActionBlocks['waitAsync_s'].xmlText([
|
||||
|
||||
@ -163,7 +163,10 @@ editor_blockly = function () {
|
||||
],
|
||||
'特效/声音':[
|
||||
MotaActionBlocks['sleep_s'].xmlText(),
|
||||
MotaActionBlocks['wait_s'].xmlText(),
|
||||
MotaActionFunctions.actionParser.parseList({"type": "wait", "data": [
|
||||
{"case": "keyboard", "keycode": 13, "action": [{"type": "comment", "text": "当按下回车(keycode=13)时执行此事件"}]},
|
||||
{"case": "mouse", "px": [0,32], "py": [0,32], "action": [{"type": "comment", "text": "当点击地图左上角时执行此事件"}]},
|
||||
]}),
|
||||
MotaActionBlocks['waitAsync_s'].xmlText(),
|
||||
MotaActionBlocks['vibrate_s'].xmlText(),
|
||||
MotaActionBlocks['animate_s'].xmlText(),
|
||||
|
||||
@ -439,6 +439,7 @@ actions.prototype._sys_ondown_lockControl = function (x, y, px, py) {
|
||||
core.setFlag('px', px);
|
||||
core.setFlag('py', py);
|
||||
core.status.route.push("input:" + (1000000 + 1000 * px + py));
|
||||
core.events.__action_wait_afterGet(core.status.event.data.current);
|
||||
core.doAction();
|
||||
}
|
||||
else {
|
||||
@ -726,6 +727,7 @@ actions.prototype._sys_onmousewheel = function (direct) {
|
||||
var keycode = direct == 1 ? 33 : 34;
|
||||
core.setFlag('keycode', keycode);
|
||||
core.status.route.push("input:" + keycode);
|
||||
core.events.__action_wait_afterGet(core.status.event.data.current);
|
||||
core.doAction();
|
||||
return;
|
||||
}
|
||||
@ -985,6 +987,7 @@ actions.prototype._keyUpAction = function (keycode) {
|
||||
core.setFlag('type', 0);
|
||||
core.setFlag('keycode', keycode);
|
||||
core.status.route.push("input:" + keycode);
|
||||
core.events.__action_wait_afterGet(core.status.event.data.current);
|
||||
core.doAction();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1910,6 +1910,7 @@ events.prototype._action_wait = function (data, x, y, prefix) {
|
||||
var value = parseInt(code.substring(6));
|
||||
core.status.route.push("input:" + value);
|
||||
this.__action_wait_getValue(value);
|
||||
this.__action_wait_afterGet(data);
|
||||
}
|
||||
else {
|
||||
main.log("录像文件出错!当前需要一个 input: 项,实际为 " + code);
|
||||
@ -1944,6 +1945,31 @@ events.prototype.__action_wait_getValue = function (value) {
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.__action_wait_afterGet = function (data) {
|
||||
if (!data.data) return;
|
||||
var todo = [];
|
||||
data.data.forEach(function (one) {
|
||||
if (one["case"] == "keyboard" && core.getFlag("type") == 0) {
|
||||
if (one["keycode"] == core.getFlag("keycode", 0)) {
|
||||
core.push(todo, one.action);
|
||||
}
|
||||
}
|
||||
if (one["case"] == "mouse" && one.px instanceof Array
|
||||
&& one.py instanceof Array && core.getFlag("type") == 1) {
|
||||
var pxmin = core.calValue(one.px[0]);
|
||||
var pxmax = core.calValue(one.px[1]);
|
||||
var pymin = core.calValue(one.py[0]);
|
||||
var pymax = core.calValue(one.py[1]);
|
||||
var px = core.getFlag("px", 0), py = core.getFlag("py", 0);
|
||||
if (px >= pxmin && px <= pxmax && py >= pymin && py <= pymax) {
|
||||
core.push(todo, one.action);
|
||||
}
|
||||
}
|
||||
})
|
||||
if (todo.length > 0)
|
||||
core.insertAction(todo);
|
||||
}
|
||||
|
||||
events.prototype._action_waitAsync = function (data, x, y, prefix) {
|
||||
var test = window.setInterval(function () {
|
||||
if (!core.hasAsync()) {
|
||||
|
||||
@ -387,7 +387,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"snowFourDirections": false,
|
||||
"bigKeyIsBox": false,
|
||||
"steelDoorWithoutKey": false,
|
||||
"itemFirstText": true,
|
||||
"itemFirstText": false,
|
||||
"equipment": false,
|
||||
"equipboxButton": false,
|
||||
"iconInEquipbox": false,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user