Merge pull request #215 from ckcz123/v2.0

Async Animate
This commit is contained in:
Zhang Chen 2018-09-18 19:10:28 +08:00 committed by GitHub
commit fcd47fd58c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 8 deletions

View File

@ -816,13 +816,13 @@ return code;
*/; */;
animate_s animate_s
: '显示动画' IdString '位置' EvalString? Newline : '显示动画' IdString '位置' EvalString? '不等待绘制完毕' Bool Newline
/* animate_s /* animate_s
tooltip : animate显示动画,位置填hero或者1,2形式的位置,或者不填代表当前事件点 tooltip : animate显示动画,位置填hero或者1,2形式的位置,或者不填代表当前事件点
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=animate%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E7%94%BB helpUrl : https://ckcz123.github.io/mota-js/#/event?id=animate%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E7%94%BB
default : ["zone","hero"] default : ["zone","hero",false]
colour : this.soundColor colour : this.soundColor
if (EvalString_0) { if (EvalString_0) {
if(/^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-]*,flag:[0-9a-zA-Z_][0-9a-zA-Z_\-]*$/.test(EvalString_0)) { if(/^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-]*,flag:[0-9a-zA-Z_][0-9a-zA-Z_\-]*$/.test(EvalString_0)) {
@ -835,7 +835,7 @@ if (EvalString_0) {
throw new Error('此处只能填hero或者1,2形式的位置,或者不填代表当前事件点'); throw new Error('此处只能填hero或者1,2形式的位置,或者不填代表当前事件点');
} }
} }
var code = '{"type": "animate", "name": "'+IdString_0+'"'+EvalString_0+'},\n'; var code = '{"type": "animate", "name": "'+IdString_0+'"'+EvalString_0+', "async": '+Bool_0+'},\n';
return code; return code;
*/; */;
@ -1803,7 +1803,7 @@ ActionParser.prototype.parseAction = function() {
var animate_loc = data.loc||''; var animate_loc = data.loc||'';
if(animate_loc && animate_loc!=='hero')animate_loc = animate_loc[0]+','+animate_loc[1]; if(animate_loc && animate_loc!=='hero')animate_loc = animate_loc[0]+','+animate_loc[1];
this.next = MotaActionBlocks['animate_s'].xmlText([ this.next = MotaActionBlocks['animate_s'].xmlText([
data.name,animate_loc,this.next]); data.name,animate_loc,data.async||0,this.next]);
break; break;
case "viberate": // 画面震动 case "viberate": // 画面震动
this.next = MotaActionBlocks['viberate_s'].xmlText([data.time||0, this.next]); this.next = MotaActionBlocks['viberate_s'].xmlText([data.time||0, this.next]);

View File

@ -753,7 +753,8 @@ name为可选的是要取消跟随的行走图文件名。
"x,y": [ // 实际执行的事件列表 "x,y": [ // 实际执行的事件列表
{"type": "animate", "name": "yongchang", "loc": [1,3]}, // 在(1,3)显示“咏唱魔法”动画 {"type": "animate", "name": "yongchang", "loc": [1,3]}, // 在(1,3)显示“咏唱魔法”动画
{"type": "animate", "name": "zone", "loc": "hero"}, // 在勇士位置显示“领域”动画 {"type": "animate", "name": "zone", "loc": "hero"}, // 在勇士位置显示“领域”动画
{"type": "animate", "name": "hand"} // 可以不指定loc则默认为当前事件点 {"type": "animate", "name": "hand"}, // 可以不指定loc则默认为当前事件点
{"type": "animate", "async": true}, // 异步,不等待动画绘制完毕
] ]
``` ```
@ -763,7 +764,9 @@ loc为动画的位置可以是`[x,y]`表示在(x,y)点显示,也可以是
loc可忽略如果忽略则显示为事件当前点。 loc可忽略如果忽略则显示为事件当前点。
在动画播放结束后才会继续执行下一个事件。 如果async指定为true则不会等待动画绘制完毕立刻执行下个事件。
否则,在动画播放结束后才会继续执行下一个事件。
### showImage显示图片 ### showImage显示图片

View File

@ -508,9 +508,15 @@ events.prototype.doAction = function() {
y=core.calValue(data.loc[1]); y=core.calValue(data.loc[1]);
} }
} }
core.drawAnimate(data.name, x, y, function () { if (data.async) {
core.drawAnimate(data.name, x, y);
core.events.doAction(); core.events.doAction();
}) }
else {
core.drawAnimate(data.name, x, y, function () {
core.events.doAction();
})
}
break; break;
case "move": // 移动事件 case "move": // 移动事件
if (core.isset(data.loc)) { if (core.isset(data.loc)) {