From e77dac115b9dd6fa98502f3e13efaea7c8ec8540 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Wed, 19 Sep 2018 12:47:11 +0800 Subject: [PATCH 1/3] fix editor:hide bg/fgmap in table ,add some '_range' in comment --- _server/comment.js | 1 + _server/data.comment.js | 7 +++++++ _server/editor_file.js | 4 ++++ _server/editor_mode.js | 29 +++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) diff --git a/_server/comment.js b/_server/comment.js index cceaf71f..a73a8956 100644 --- a/_server/comment.js +++ b/_server/comment.js @@ -118,6 +118,7 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "special": { "_leaf": true, "_type": "textarea", + "_range": "thiseval==null || thiseval instanceof Array || (thiseval==~~thiseval && thiseval>0)", "_data": "特殊属性\n\n0:无,1:先攻,2:魔攻,3:坚固,4:2连击,\n5:3连击,6:n连击,7:破甲,8:反击,9:净化,\n10:模仿,11:吸血,12:中毒,13:衰弱,14:诅咒,\n15:领域,16:夹击,17:仇恨,18:阻击,19:自爆,\n20:无敌,21:退化,22:固伤,23:重生,24:激光\n\n多个属性例如用[1,4,11]表示先攻2连击吸血\n模仿怪的攻防设为0就好" }, "value": { diff --git a/_server/data.comment.js b/_server/data.comment.js index 9b678051..2a07d140 100644 --- a/_server/data.comment.js +++ b/_server/data.comment.js @@ -10,6 +10,7 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "floorIds": { "_leaf": true, "_type": "textarea", + "_range": "editor.mode.checkFloorIds(thiseval)", "_data": "在这里按顺序放所有的楼层;其顺序直接影响到楼层传送器、浏览地图和上/下楼器的顺序" }, "images": { @@ -45,11 +46,13 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "levelChoose": { "_leaf": true, "_type": "textarea", + "_range": "thiseval instanceof Array && thiseval.length>=1 && thiseval[0] instanceof Array && thiseval[0].length==2", "_data": "难度选择:每个数组的第一个是其在标题界面显示的难度,第二个是在游戏内部传输的字符串,会显示在状态栏,修改此处后需要在project/functions中作相应更改" }, "equipName": { "_leaf": true, "_type": "textarea", + "_range": "(thiseval instanceof Array && thiseval.length<=6)||thiseval==null", "_data": "装备位名称,为不超过6个的数组,此项的顺序与equiptype数值关联;例如可写[\"武器\",\"防具\",\"首饰\"]等等。" }, "statusLeftBackground": { @@ -97,6 +100,7 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "floorId": { "_leaf": true, "_type": "textarea", + "_range": "data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.floorIds.indexOf(thiseval)!==-1", "_data": "初始楼层的ID" }, "hero": { @@ -222,17 +226,20 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_leaf": true, "_type": "event", "_event": "firstArrive", + "_range": "thiseval==null || thiseval instanceof Array", "_data": "游戏开始前剧情。\n可以双击进入事件编辑器。\n如果无剧情直接留一个空数组即可。" }, "shops": { "_leaf": true, "_type": "event", "_event": "shop", + "_range": "thiseval instanceof Array", "_data": "全局商店,是一个数组,可以双击进入事件编辑器。" }, "levelUp": { "_leaf": true, "_type": "textarea", + "_range": "thiseval==null || thiseval instanceof Array", "_data": "经验升级所需要的数值,是一个数组,可以双击进行编辑。 \n 第一项为初始等级,可以简单留空,也可以写name \n 每一个里面可以含有三个参数 need, name, effect \n need为所需要的经验数值,是一个正整数。请确保need所需的依次递增 \n name为该等级的名称,也可以省略代表使用系统默认值;本项将显示在状态栏中 \n effect为本次升级所执行的操作,可由若干项组成,由分号分开 \n 其中每一项写法和上面的商店完全相同,同样必须是X+=Y的形式,Y是一个表达式,同样可以使用status:xxx或item:xxx代表勇士的某项数值/道具个数" } } diff --git a/_server/editor_file.js b/_server/editor_file.js index 8e340f4b..e0ce6877 100644 --- a/_server/editor_file.js +++ b/_server/editor_file.js @@ -565,6 +565,8 @@ editor_file = function (editor, callback) { delete(locObj[v]); }); delete(locObj.map); + delete(locObj.bgmap); + delete(locObj.fgmap); return locObj; })(), editor_file.comment._data.floors._data.floor, @@ -584,6 +586,8 @@ editor_file = function (editor, callback) { delete(locObj[v]); }); delete(locObj.map); + delete(locObj.bgmap); + delete(locObj.fgmap); return locObj; })(), editor_file.comment._data.floors._data.floor, diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 3fe44261..bf4fe47c 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -71,6 +71,7 @@ editor_mode = function (editor) { if (key === '_data') continue; if (cobj[key] instanceof Function) cobj[key] = cobj[key](args); } + if (cobj._hide)continue; if (cobj._leaf) { var leafnode = editor_mode.objToTr_(obj, commentObj, field, cfield, vobj, cobj); outstr.push(leafnode[0]); @@ -649,6 +650,34 @@ editor_mode = function (editor) { if(editor.isMobile)editor.showdataarea(false); } + editor_mode.checkFloorIds = function(thiseval){ + var oldvalue = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.floorIds; + fs.readdir('project/floors',function(err, data){ + if(err){ + printe(err); + throw Error(err); + } + var newfiles=thiseval.map(function(v){return v+'.js'}); + var notExist=''; + for(var name,ii=0;name=newfiles[ii];ii++){ + if(data.indexOf(name)===-1)notExist=name; + } + if(notExist){ + var discard=confirm('文件'+notExist+'不存在, 保存会导致工程无法打开, 是否放弃更改'); + if(discard){ + editor.file.editTower([['change', "['main']['floorIds']", oldvalue]], function (objs_) {/*console.log(objs_);*/ + if (objs_.slice(-1)[0] != null) { + printe(objs_.slice(-1)[0]); + throw(objs_.slice(-1)[0]) + } + ;printe('已放弃floorIds的修改'); + }); + } + } + }); + return true + } + if (Boolean(callback)) callback(); } From 8e234d396c2aec821e2754b7911209451d8d2c46 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 19 Sep 2018 20:40:40 +0800 Subject: [PATCH 2/3] Fix Bg/Fg map in floors --- _server/comment.js | 2 +- _server/data.comment.js | 2 +- libs/control.js | 2 ++ libs/ui.js | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/_server/comment.js b/_server/comment.js index a73a8956..f393526f 100644 --- a/_server/comment.js +++ b/_server/comment.js @@ -118,7 +118,7 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "special": { "_leaf": true, "_type": "textarea", - "_range": "thiseval==null || thiseval instanceof Array || (thiseval==~~thiseval && thiseval>0)", + "_range": "thiseval==null || thiseval instanceof Array || (thiseval==~~thiseval && thiseval>=0)", "_data": "特殊属性\n\n0:无,1:先攻,2:魔攻,3:坚固,4:2连击,\n5:3连击,6:n连击,7:破甲,8:反击,9:净化,\n10:模仿,11:吸血,12:中毒,13:衰弱,14:诅咒,\n15:领域,16:夹击,17:仇恨,18:阻击,19:自爆,\n20:无敌,21:退化,22:固伤,23:重生,24:激光\n\n多个属性例如用[1,4,11]表示先攻2连击吸血\n模仿怪的攻防设为0就好" }, "value": { diff --git a/_server/data.comment.js b/_server/data.comment.js index 2a07d140..634859e7 100644 --- a/_server/data.comment.js +++ b/_server/data.comment.js @@ -47,7 +47,7 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_leaf": true, "_type": "textarea", "_range": "thiseval instanceof Array && thiseval.length>=1 && thiseval[0] instanceof Array && thiseval[0].length==2", - "_data": "难度选择:每个数组的第一个是其在标题界面显示的难度,第二个是在游戏内部传输的字符串,会显示在状态栏,修改此处后需要在project/functions中作相应更改" + "_data": "难度选择:每个数组的第一个是其在标题界面显示的难度,第二个是在游戏内部传输的字符串,会显示在状态栏,修改此处后需要在project/functions中作相应更改。\n如果需直接开始游戏将下面的startDirectly开关打开即可。" }, "equipName": { "_leaf": true, diff --git a/libs/control.js b/libs/control.js index 962c6c09..3993a827 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1526,6 +1526,8 @@ control.prototype.updateDamage = function () { damage = core.formatBigNumber(damage); if (core.enemys.hasSpecial(core.material.enemys[id], 19)) damage += "+"; + if (core.enemys.hasSpecial(core.material.enemys[id], 21)) + damage += "-"; } core.setFillStyle('damage', '#000000'); diff --git a/libs/ui.js b/libs/ui.js index eb94dcdf..840656f7 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1388,6 +1388,8 @@ ui.prototype.drawBook = function (index) { damage = core.formatBigNumber(damage); if (core.enemys.hasSpecial(core.material.enemys[enemy.id], 19)) damage += "+"; + if (core.enemys.hasSpecial(core.material.enemys[enemy.id], 21)) + damage += "-"; } if (core.material.enemys[enemy.id].notBomb) damage += "[b]"; From feaa250a9c8f826e5deb9c01f574a98b5969d560 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 19 Sep 2018 21:17:43 +0800 Subject: [PATCH 3/3] Async events --- _server/blockly/MotaAction.g4 | 70 +++++++++++++++++++---------------- docs/event.md | 22 ++++++++--- libs/events.js | 60 ++++++++++++++++++++++-------- 3 files changed, 101 insertions(+), 51 deletions(-) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index b4e4f01d..b9729956 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -802,21 +802,22 @@ return code; */; viberate_s - : '画面震动' '时间' Int Newline + : '画面震动' '时间' Int '异步' Bool Newline /* viberate_s tooltip : viberate: 画面震动 helpUrl : https://ckcz123.github.io/mota-js/#/event?id=viberate%ef%bc%9a%e7%94%bb%e9%9d%a2%e9%9c%87%e5%8a%a8 -default : [2000] +default : [2000,false] colour : this.soundColor Int_0 = Int_0 ?(', "time": '+Int_0):''; -var code = '{"type": "viberate"' + Int_0 + '},\n'; +var async = Bool_0?', "async": true':'' +var code = '{"type": "viberate"' + Int_0 + async + '},\n'; return code; */; animate_s - : '显示动画' IdString '位置' EvalString? '不等待绘制完毕' Bool Newline + : '显示动画' IdString '位置' EvalString? '异步' Bool Newline /* animate_s @@ -835,7 +836,8 @@ if (EvalString_0) { throw new Error('此处只能填hero或者1,2形式的位置,或者不填代表当前事件点'); } } -var code = '{"type": "animate", "name": "'+IdString_0+'"'+EvalString_0+', "async": '+Bool_0+'},\n'; +var async = Bool_0?', "async": true':''; +var code = '{"type": "animate", "name": "'+IdString_0+'"'+EvalString_0+async+'},\n'; return code; */; @@ -865,28 +867,30 @@ return code; */; animateImage_0_s - : '图片淡入' EvalString '起点像素位置' 'x' PosString 'y' PosString '动画时间' Int Newline + : '图片淡入' EvalString '起点像素位置' 'x' PosString 'y' PosString '动画时间' Int '异步' Bool Newline /* animateImage_0_s tooltip : animageImage:图片淡入 helpUrl : https://ckcz123.github.io/mota-js/#/event?id=animateimage%EF%BC%9A%E5%9B%BE%E7%89%87%E6%B7%A1%E5%85%A5%E6%B7%A1%E5%87%BA -default : ["bg.jpg","0","0",500] +default : ["bg.jpg","0","0",500,false] colour : this.printColor -var code = '{"type": "animateImage", "action": "show", "name": "'+EvalString_0+'", "loc": ['+PosString_0+','+PosString_1+'], "time": '+Int_0+'},\n'; +var async = Bool_0?', "async": true':''; +var code = '{"type": "animateImage", "action": "show", "name": "'+EvalString_0+'", "loc": ['+PosString_0+','+PosString_1+'], "time": '+Int_0+async+'},\n'; return code; */; animateImage_1_s - : '图片淡出' EvalString '起点像素位置' 'x' PosString 'y' PosString '动画时间' Int Newline + : '图片淡出' EvalString '起点像素位置' 'x' PosString 'y' PosString '动画时间' Int '异步' Bool Newline /* animateImage_1_s tooltip : animageImage:图片淡出 helpUrl : https://ckcz123.github.io/mota-js/#/event?id=animateimage%EF%BC%9A%E5%9B%BE%E7%89%87%E6%B7%A1%E5%85%A5%E6%B7%A1%E5%87%BA -default : ["bg.jpg","0","0",500] +default : ["bg.jpg","0","0",500,false] colour : this.printColor -var code = '{"type": "animateImage", "action": "hide", "name": "'+EvalString_0+'", "loc": ['+PosString_0+','+PosString_1+'], "time": '+Int_0+'},\n'; +var async = Bool_0?', "async": true':''; +var code = '{"type": "animateImage", "action": "hide", "name": "'+EvalString_0+'", "loc": ['+PosString_0+','+PosString_1+'], "time": '+Int_0+async+'},\n'; return code; */; @@ -917,26 +921,27 @@ return code; moveImage_0_s : '图片移动' EvalString '起点像素位置' 'x' PosString 'y' PosString BGNL - '终点像素位置' 'x' PosString 'y' PosString '移动时间' Int Newline + '终点像素位置' 'x' PosString 'y' PosString '移动时间' Int '异步' Bool Newline /* moveImage_0_s tooltip : moveImage:图片移动 helpUrl : https://ckcz123.github.io/mota-js/#/event?id=moveimage%EF%BC%9A%E5%9B%BE%E7%89%87%E7%A7%BB%E5%8A%A8 -default : ["bg.jpg","0","0","0","0",500] +default : ["bg.jpg","0","0","0","0",500,false] colour : this.printColor -var code = '{"type": "moveImage", "name": "'+EvalString_0+'", "from": ['+PosString_0+','+PosString_1+'], "to": ['+PosString_2+','+PosString_3+'], "time": '+Int_0+'},\n'; +var async = Bool_0?', "async": true':''; +var code = '{"type": "moveImage", "name": "'+EvalString_0+'", "from": ['+PosString_0+','+PosString_1+'], "to": ['+PosString_2+','+PosString_3+'], "time": '+Int_0+async+'},\n'; return code; */; setFg_0_s - : '更改画面色调' Number ',' Number ',' Number ',' Number '动画时间' Int? Newline + : '更改画面色调' Number ',' Number ',' Number ',' Number '动画时间' Int? '异步' Bool Newline /* setFg_0_s tooltip : setFg: 更改画面色调,动画时间可不填 helpUrl : https://ckcz123.github.io/mota-js/#/event?id=setfg%EF%BC%9A%E6%9B%B4%E6%94%B9%E7%94%BB%E9%9D%A2%E8%89%B2%E8%B0%83 -default : [255,255,255,1,500] +default : [255,255,255,1,500,false] colour : this.soundColor var limit = function(v,min,max) { if(v>max) return max; @@ -948,21 +953,23 @@ Number_1 = limit(Number_1,0,255); Number_2 = limit(Number_2,0,255); Number_3 = limit(Number_3,0,1); Int_0 = Int_0 ?(', "time": '+Int_0):''; -var code = '{"type": "setFg", "color": ['+Number_0+','+Number_1+','+Number_2+','+Number_3+']'+Int_0 +'},\n'; +var async = Bool_0?', "async": true':''; +var code = '{"type": "setFg", "color": ['+Number_0+','+Number_1+','+Number_2+','+Number_3+']'+Int_0 +async+'},\n'; return code; */; setFg_1_s - : '恢复画面色调' '动画时间' Int? Newline + : '恢复画面色调' '动画时间' Int? '异步' Bool Newline /* setFg_1_s tooltip : setFg: 恢复画面色调,动画时间可不填 helpUrl : https://ckcz123.github.io/mota-js/#/event?id=setfg%EF%BC%9A%E6%9B%B4%E6%94%B9%E7%94%BB%E9%9D%A2%E8%89%B2%E8%B0%83 -default : [500] +default : [500,false] colour : this.soundColor Int_0 = Int_0 ?(', "time": '+Int_0):''; -var code = '{"type": "setFg"'+Int_0 +'},\n'; +var async = Bool_0?', "async": true':''; +var code = '{"type": "setFg"'+Int_0 +async+'},\n'; return code; */; @@ -1103,16 +1110,17 @@ return code; */; setVolume_s - : '设置音量' Int '渐变时间' Int? Newline + : '设置音量' Int '渐变时间' Int? '异步' Bool Newline /* setVolume_s tooltip : setVolume: 设置音量 helpUrl : https://ckcz123.github.io/mota-js/#/event?id=setvolume%EF%BC%9A%E8%AE%BE%E7%BD%AE%E9%9F%B3%E9%87%8F -default : [90, 500] +default : [90, 500, false] colour : this.soundColor Int_1 = Int_1?(', "time": '+Int_1):"" -var code = '{"type": "setVolume", "value": '+Int_0+Int_1+'},\n'; +var async = Bool_0?', "async": true':''; +var code = '{"type": "setVolume", "value": '+Int_0+Int_1+async+'},\n'; return code; */; @@ -1803,10 +1811,10 @@ ActionParser.prototype.parseAction = function() { 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.async||0,this.next]); + data.name,animate_loc,data.async||false,this.next]); break; case "viberate": // 画面震动 - this.next = MotaActionBlocks['viberate_s'].xmlText([data.time||0, this.next]); + this.next = MotaActionBlocks['viberate_s'].xmlText([data.time||0, data.async||false, this.next]); break; case "showImage": // 显示图片 if(this.isset(data.name)){ @@ -1820,10 +1828,10 @@ ActionParser.prototype.parseAction = function() { case "animateImage": // 显示图片 if(data.action == 'show'){ this.next = MotaActionBlocks['animateImage_0_s'].xmlText([ - data.name,data.loc[0],data.loc[1],data.time,this.next]); + data.name,data.loc[0],data.loc[1],data.time,data.async||false,this.next]); } else if (data.action == 'hide') { this.next = MotaActionBlocks['animateImage_1_s'].xmlText([ - data.name,data.loc[0],data.loc[1],data.time,this.next]); + data.name,data.loc[0],data.loc[1],data.time,data.async||false,this.next]); } break; case "showGif": // 显示动图 @@ -1837,7 +1845,7 @@ ActionParser.prototype.parseAction = function() { break; case "moveImage": // 移动图片 this.next = MotaActionBlocks['moveImage_0_s'].xmlText([ - data.name, data.from[0], data.from[1], data.to[0], data.to[1], data.time, this.next + data.name, data.from[0], data.from[1], data.to[0], data.to[1], data.time, data.async||false, this.next ]); break; case "setFg": // 颜色渐变 @@ -1845,10 +1853,10 @@ ActionParser.prototype.parseAction = function() { var alpha = data.color[3]; if (alpha==undefined || alpha==null) alpha=1; this.next = MotaActionBlocks['setFg_0_s'].xmlText([ - data.color[0],data.color[1],data.color[2],alpha,data.time||0,this.next]); + data.color[0],data.color[1],data.color[2],alpha,data.time||0,data.async||false,this.next]); } else { this.next = MotaActionBlocks['setFg_1_s'].xmlText([ - data.time||0,this.next]); + data.time||0,data.async||false,this.next]); } break; case "setWeather": // 更改天气 @@ -1894,7 +1902,7 @@ ActionParser.prototype.parseAction = function() { break case "setVolume": this.next = MotaActionBlocks['setVolume_s'].xmlText([ - data.value, data.time, this.next]); + data.value, data.time, data.async||false, this.next]); break case "setValue": this.next = MotaActionBlocks['setValue_s'].xmlText([ diff --git a/docs/event.md b/docs/event.md index 0b788098..34ce372d 100644 --- a/docs/event.md +++ b/docs/event.md @@ -741,7 +741,11 @@ name为可选的,是要取消跟随的行走图文件名。 ### viberate:画面震动 -使用 `{"type": "viberate", "time": 2000}` 可以造成画面震动效果,后面time可以指定震动时间。 +使用 `{"type": "viberate", "time": 2000, "async": true}` 可以造成画面震动效果。 + +time可以指定震动时间,默认是2000毫秒。 + +async可选,如果为true则会异步执行(即不等待当前事件执行完毕,立刻执行下一个事件)。 ### animate:显示动画 @@ -795,7 +799,7 @@ loc为图片左上角坐标,以像素为单位进行计算。 ``` js "x,y": [ // 实际执行的事件列表 {"type": "animateImage", "action": "show", "name": "bg.jpg", "loc": [231,297], "time": 500}, // 在(231,297)淡入bg.jpg,动画时间500ms - {"type": "animateImage", "action": "hide", "name": "1.png", "loc": [109,167], "time": 300}, // 在(109,167)淡出1.png,动画时间300ms + {"type": "animateImage", "action": "hide", "name": "1.png", "loc": [109,167], "time": 300, "async": true}, // 在(109,167)淡出1.png,动画时间300ms,异步执行 ] ``` @@ -807,6 +811,8 @@ loc为图片左上角坐标,以像素为单位进行计算。 time为淡入淡出的时间,如果是0则忽略此项。 +async可选,如果为true则会异步执行(即不等待当前事件执行完毕,立刻执行下一个事件)。 + !> 淡入淡出图片只是会在顶层绘制“淡入”和“淡出”效果,动画结束即消失,并不会实际对图片的显示造成影响。请与showImage事件合用。 如果多张图片的淡入淡出可以采用以下方式(仅供参考): @@ -838,7 +844,7 @@ loc为动图左上角坐标,以像素为单位进行计算。 ``` js "x,y": [ // 实际执行的事件列表 - {"type": "moveImage", "name": "bg.jpg", "from": [231,297], "to": [22,333], "time": 500}, + {"type": "moveImage", "name": "bg.jpg", "from": [231,297], "to": [22,333], "time": 500, "async": true}, ] ``` @@ -850,6 +856,8 @@ to为终点图片左上角坐标,以像素为单位进行计算。 time为总移动的时间。 +async可选,如果为true则会异步执行(即不等待当前事件执行完毕,立刻执行下一个事件)。 + !> 移动图片只是会在顶层绘制“移动”效果,动画结束即消失,并不会实际对图片的显示造成影响。请与showImage事件合用。 ### setFg:更改画面色调 @@ -859,7 +867,7 @@ time为总移动的时间。 ``` js "x,y": [ // 实际执行的事件列表 {"type": "setFg", "color": [255,255,255,0.6], "time": 1000}, // 更改画面色调为纯白,不透明度0.6,动画时间1000毫秒 - {"type": "setFg", "color": [0,0,0]}, // 更改画面色调为纯黑,不透明度1,不指定动画时间(使用默认时间) + {"type": "setFg", "color": [0,0,0], "async": true}, // 更改画面色调为纯黑,不透明度1,不指定动画时间(使用默认时间),且异步执行 {"type": "setFg"} // 如果不指定color则恢复原样。 ] ``` @@ -872,6 +880,8 @@ color为需要更改画面色调的颜色。它是一个数组,分别指定目 time为可选的,如果指定,则会作为更改画面色调的时间。 +async可选,如果为true则会异步执行(即不等待当前事件执行完毕,立刻执行下一个事件)。 + ### setWeather:更改天气 我们可以使用 `{"type": "setWeather"}` 来更改天气。 @@ -1030,12 +1040,14 @@ time选项为该跳跃所需要用到的时间。 使用setVolume可以设置音量大小。 -使用方法: `{"type": "setVolume", "value": 90, "time": 500}` +使用方法: `{"type": "setVolume", "value": 90, "time": 500, "async": true}` value为音量大小,在0到100之间,默认为100。设置后,BGM和SE都将使用该音量进行播放。 可以设置time为音量渐变时间。 +async可选,如果为true则会异步执行(即不等待当前事件执行完毕,立刻执行下一个事件)。 + ### win:获得胜利 `{"type": "win", "reason": "xxx"}` 将会直接调用events.js中的win函数,并将reason作为结局传入。 diff --git a/libs/events.js b/libs/events.js index c39f31e7..0eca9ad7 100644 --- a/libs/events.js +++ b/libs/events.js @@ -594,9 +594,15 @@ events.prototype.doAction = function() { } else { if (core.isset(data.loc) && core.isset(core.material.images.images[data.name]) && (data.action=="show" || data.action=="hide")) { - core.events.animateImage(data.action, core.material.images.images[data.name], data.loc, data.time, function() { - core.events.doAction(); - }); + if (data.async) { + core.events.animateImage(data.action, core.material.images.images[data.name], data.loc, data.time); + this.doAction(); + } + else { + core.events.animateImage(data.action, core.material.images.images[data.name], data.loc, data.time, function() { + core.events.doAction(); + }); + } } else { this.doAction(); @@ -625,9 +631,15 @@ events.prototype.doAction = function() { } else { if (core.isset(data.from) && core.isset(data.to) && core.isset(core.material.images.images[data.name])) { - core.events.moveImage(core.material.images.images[data.name], data.from, data.to, data.time, function() { - core.events.doAction(); - }); + if (data.async) { + core.events.moveImage(core.material.images.images[data.name], data.from, data.to, data.time); + this.doAction(); + } + else { + core.events.moveImage(core.material.images.images[data.name], data.from, data.to, data.time, function() { + core.events.doAction(); + }); + } } else { this.doAction(); @@ -635,9 +647,15 @@ events.prototype.doAction = function() { } break; case "setFg": // 颜色渐变 - core.setFg(data.color, data.time, function() { - core.events.doAction(); - }); + if (data.async) { + core.setFg(data.color, data.time); + this.doAction(); + } + else { + core.setFg(data.color, data.time, function() { + core.events.doAction(); + }); + } break; case "setWeather": // 更改天气 core.setWeather(data.name, data.level); @@ -722,9 +740,15 @@ events.prototype.doAction = function() { data.value = parseInt(data.value||0); if (data.value<0) data.value=0; if (data.value>100) data.value=100; - this.setVolume(data.value/100, data.time, function() { - core.doAction(); - }); + if (data.async) { + this.setVolume(data.value/100, data.time); + this.doAction(); + } + else { + this.setVolume(data.value/100, data.time, function() { + core.events.doAction(); + }); + } break; case "setValue": try { @@ -896,9 +920,15 @@ events.prototype.doAction = function() { this.doAction(); break; case "viberate": - core.events.vibrate(data.time, function () { - core.events.doAction(); - }) + if (data.async) { + core.events.vibrate(data.time); + this.doAction(); + } + else { + core.events.vibrate(data.time, function () { + core.events.doAction(); + }) + } break; case "sleep": // 等待多少毫秒 if (core.status.replay.replaying)