type:wait preview
This commit is contained in:
parent
8ef2cc11a0
commit
ef45e9f7d9
@ -1964,6 +1964,31 @@ yes和no均为必填项,即用户点击确认或取消后执行的事件。
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
从V2.6.6开始,也允许直接在`type:wait`中增加`data`项判定按键或点击坐标。
|
||||||
|
|
||||||
|
```js
|
||||||
|
[
|
||||||
|
{"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": "当点击地图左上角时执行此事件"},
|
||||||
|
]},
|
||||||
|
]},
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
`data`是一个数组,每一项中,case只能为`keyboard`和`mouse`二选一,分别对应键盘和鼠标(即`type=0`和`type=1`)。
|
||||||
|
|
||||||
|
如果是键盘,则可以指定`keycode`为键盘的按键内容;否则指定`px`和`py`为点击的像素区间。
|
||||||
|
|
||||||
|
action为如果满足该条件时应该执行的事件列表。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### waitAsync:等待所有异步事件执行完毕
|
### waitAsync:等待所有异步事件执行完毕
|
||||||
|
|
||||||
上面有很多很多的异步事件(也就是执行时不等待执行完毕)。
|
上面有很多很多的异步事件(也就是执行时不等待执行完毕)。
|
||||||
|
|||||||
BIN
_docs/img/events/52.png
Normal file
BIN
_docs/img/events/52.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 104 KiB |
@ -2020,14 +2020,14 @@ return code;
|
|||||||
|
|
||||||
|
|
||||||
waitContext_2
|
waitContext_2
|
||||||
: '点击的场合' '像素x范围' Int '~' Int '; y范围' Int '~' Int BGNL? Newline action+ BEND Newline
|
: '点击的场合' '像素x范围' PosString '~' PosString '; y范围' PosString '~' PosString BGNL? Newline action+ BEND Newline
|
||||||
|
|
||||||
/* waitContext_2
|
/* waitContext_2
|
||||||
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
|
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]
|
default : [0,32,0,32]
|
||||||
colour : this.subColor
|
colour : this.subColor
|
||||||
var code = '{"case": "mouse", "px": [' + Int_0 + ',' + Int_1 + '], "py": [' + Int_2 + ',' + Int_3 + '], "action": [\n' + action_0 + ']},\n';
|
var code = '{"case": "mouse", "px": [' + PosString_0 + ',' + PosString_1 + '], "py": [' + PosString_2 + ',' + PosString_3 + '], "action": [\n' + action_0 + ']},\n';
|
||||||
return code;
|
return code;
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
|
|||||||
@ -159,7 +159,7 @@ editor.prototype.init = function (callback) {
|
|||||||
editor.mode = editor_mode;
|
editor.mode = editor_mode;
|
||||||
core.resetGame(core.firstData.hero, null, core.firstData.floorId, core.clone(core.initStatus.maps));
|
core.resetGame(core.firstData.hero, null, core.firstData.floorId, core.clone(core.initStatus.maps));
|
||||||
var lastFloorId = core.getLocalStorage('editorLastFloorId', core.status.floorId);
|
var lastFloorId = core.getLocalStorage('editorLastFloorId', core.status.floorId);
|
||||||
if (core.floors.indexOf(lastFloorId) < 0) lastFloorId = core.status.floorId;
|
if (core.floorIds.indexOf(lastFloorId) < 0) lastFloorId = core.status.floorId;
|
||||||
core.changeFloor(lastFloorId, null, core.firstData.hero.loc, null, function () {
|
core.changeFloor(lastFloorId, null, core.firstData.hero.loc, null, function () {
|
||||||
afterCoreReset();
|
afterCoreReset();
|
||||||
}, true);
|
}, true);
|
||||||
|
|||||||
@ -692,14 +692,20 @@ function omitedcheckUpdateFunction(event) {
|
|||||||
"previewUI_s", "clearMap_s", "clearMap_1_s", "setAttribute_s", "fillText_s",
|
"previewUI_s", "clearMap_s", "clearMap_1_s", "setAttribute_s", "fillText_s",
|
||||||
"fillBoldText_s", "fillRect_s", "strokeRect_s", "drawLine_s",
|
"fillBoldText_s", "fillRect_s", "strokeRect_s", "drawLine_s",
|
||||||
"drawArrow_s", "fillPolygon_s", "strokePolygon_s", "fillCircle_s", "strokeCircle_s",
|
"drawArrow_s", "fillPolygon_s", "strokePolygon_s", "fillCircle_s", "strokeCircle_s",
|
||||||
"drawImage_s", "drawImage_1_s", "drawIcon_s", "drawBackground_s", "drawSelector_s", "drawSelector_1_s"
|
"drawImage_s", "drawImage_1_s", "drawIcon_s", "drawBackground_s", "drawSelector_s", "drawSelector_1_s",
|
||||||
|
"waitContext_2"
|
||||||
];
|
];
|
||||||
if (b && types.indexOf(b.type)>=0) {
|
if (b && types.indexOf(b.type)>=0) {
|
||||||
try {
|
try {
|
||||||
var code = "[" + Blockly.JavaScript.blockToCode(b).replace(/\\(i|c|d|e)/g, '\\\\$1') + "]";
|
var code = "[" + Blockly.JavaScript.blockToCode(b).replace(/\\(i|c|d|e)/g, '\\\\$1') + "]";
|
||||||
eval("var obj="+code);
|
eval("var obj="+code);
|
||||||
// console.log(obj);
|
if (obj.length > 0 && b.type == 'waitContext_2') {
|
||||||
if (obj.length > 0 && b.type.startsWith(obj[0].type)) {
|
var dt = obj[0];
|
||||||
|
editor.uievent.previewUI([{"type": "fillRect", "x": dt.px[0], "y": dt.py[0],
|
||||||
|
"width": "(" + dt.px[1] + ")-(" + dt.px[0] + ")", "height": "(" + dt.py[1] + ")-(" + dt.py[0] + ")",
|
||||||
|
"style": "#FF0000"}])
|
||||||
|
}
|
||||||
|
else if (obj.length > 0 && b.type.startsWith(obj[0].type)) {
|
||||||
if (b.type == 'previewUI_s')
|
if (b.type == 'previewUI_s')
|
||||||
editor.uievent.previewUI(obj[0].action);
|
editor.uievent.previewUI(obj[0].action);
|
||||||
else editor.uievent.previewUI([obj[0]]);
|
else editor.uievent.previewUI([obj[0]]);
|
||||||
|
|||||||
@ -1970,6 +1970,17 @@ events.prototype.__action_wait_afterGet = function (data) {
|
|||||||
core.insertAction(todo);
|
core.insertAction(todo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events.prototype._precompile_wait = function (data) {
|
||||||
|
if (data.data) {
|
||||||
|
data.data.forEach(function (v) {
|
||||||
|
if (v.px) v.px = this.__precompile_array(v.px);
|
||||||
|
if (v.py) v.py = this.__precompile_array(v.py);
|
||||||
|
v.action = this.precompile(v.action);
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
events.prototype._action_waitAsync = function (data, x, y, prefix) {
|
events.prototype._action_waitAsync = function (data, x, y, prefix) {
|
||||||
var test = window.setInterval(function () {
|
var test = window.setInterval(function () {
|
||||||
if (!core.hasAsync()) {
|
if (!core.hasAsync()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user