From 0743875310a9691e78face876ee60a5a6cb95770 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 23 Jul 2021 14:37:28 +0800 Subject: [PATCH] Add animate_1_s --- _server/MotaAction.g4 | 39 +++++++++++++++++++-------------- _server/MotaActionParser.js | 12 ++++++---- _server/editor_blocklyconfig.js | 1 + 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 60658a76..8085ddc7 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -697,6 +697,7 @@ action | follow_s | unfollow_s | animate_s + | animate_1_s | vibrate_s | showImage_s | showImage_1_s @@ -1883,31 +1884,37 @@ return code; */; animate_s - : '显示动画' IdString '位置' EvalString? '相对窗口坐标' Bool '不等待执行完毕' Bool Newline + : '显示动画' IdString '位置' 'x' PosString? 'y' PosString? '相对窗口坐标' Bool '不等待执行完毕' Bool Newline /* animate_s tooltip : animate:显示动画,位置填hero或者1,2形式的位置,或者不填代表当前事件点 helpUrl : /_docs/#/instruction -default : ["zone","hero",false,false] +default : ["zone","","",false,false] allAnimates : ['IdString_0'] material : ["./project/animates/", "IdString_0"] -menu : [['选择位置','editor_blockly.selectPoint(block,["EvalString_0","EvalString_0"])']] +selectPoint : ["PosString_0", "PosString_1"] colour : this.soundColor -if (EvalString_0) { - if(MotaActionFunctions.pattern.id2.test(EvalString_0)) { - EvalString_0=', "loc": ["'+EvalString_0.split(',').join('","')+'"]'; - } else if (/hero|([+-]?\d+),([+-]?\d+)/.test(EvalString_0)) { - if(EvalString_0.indexOf(',')!==-1)EvalString_0='['+EvalString_0+']'; - else EvalString_0='"'+EvalString_0+'"'; - EvalString_0 = ', "loc": '+EvalString_0; - } else { - throw new Error('此处只能填hero或者1,2形式的位置,或者不填代表当前事件点'); - } -} +var loc = PosString_0&&PosString_1?(', "loc": ['+PosString_0+','+PosString_1+']'):''; Bool_0 = Bool_0?', "alignWindow": true':''; -var async = Bool_1?', "async": true':''; -var code = '{"type": "animate", "name": "'+IdString_0+'"'+EvalString_0+Bool_0+async+'},\n'; +Bool_1 = Bool_1?', "async": true':''; +var code = '{"type": "animate", "name": "'+IdString_0+'"'+loc+Bool_0+Bool_1+'},\n'; +return code; +*/; + +animate_1_s + : '显示角色动画' IdString '不等待执行完毕' Bool Newline + + +/* animate_1_s +tooltip : animate:显示角色动画 +helpUrl : /_docs/#/instruction +default : ["zone",false] +allAnimates : ['IdString_0'] +material : ["./project/animates/", "IdString_0"] +colour : this.soundColor +Bool_0 = Bool_0?', "async": true':''; +var code = '{"type": "animate", "name": "'+IdString_0+'", "loc": "hero"'+Bool_0+'},\n'; return code; */; diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index 5cb79336..b0fce8c7 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -473,10 +473,14 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['unfollow_s'].xmlText([data.name||"", this.next]); break; case "animate": // 显示动画 - var animate_loc = data.loc||''; - if(animate_loc && animate_loc!=='hero')animate_loc = animate_loc[0]+','+animate_loc[1]; - this.next = MotaActionBlocks['animate_s'].xmlText([ - data.name,animate_loc,data.alignWindow||false,data.async||false,this.next]); + if (data.loc == 'hero') { + this.next = MotaActionBlocks['animate_1_s'].xmlText([ + data.name,data.async||false,this.next]); + } else { + data.loc=data.loc||['','']; + this.next = MotaActionBlocks['animate_s'].xmlText([ + data.name,data.loc[0],data.loc[1],data.alignWindow||false,data.async||false,this.next]); + } break; case "setViewport": // 设置视角 if (data.dxy) { diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index 171e9217..53ce390a 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -189,6 +189,7 @@ editor_blocklyconfig=(function(){ MotaActionBlocks['waitAsync_s'].xmlText(), MotaActionBlocks['vibrate_s'].xmlText(), MotaActionBlocks['animate_s'].xmlText(), + MotaActionBlocks['animate_1_s'].xmlText(), MotaActionBlocks['setViewport_s'].xmlText(), MotaActionBlocks['setViewport_1_s'].xmlText(), MotaActionBlocks['showStatusBar_s'].xmlText(),