diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index efa8695b..09610c7d 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -270,6 +270,7 @@ action | showGif_1_s | setFg_0_s | setFg_1_s + | screenFlash_s | setWeather_s | move_s | moveHero_s @@ -1155,6 +1156,29 @@ var code = '{"type": "setFg"'+Int_0 +async+'},\n'; return code; */; +screenFlash_s + : '画面闪烁' Number ',' Number ',' Number '强度' Number '单次时间' Int '执行次数' Int? '不等待执行完毕' Bool Newline + +/* screenFlash_s +tooltip : screenFlash: 画面闪烁,动画时间可不填 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=screenFlash%EF%BC%9A%E7%94%BB%E9%9D%A2%E9%97%AA%E7%83%81 +default : [255,255,255,1,500,1,false] +colour : this.soundColor +var limit = function(v,min,max) { + if(v>max) return max; + if(v=steps) { + if (step <= 0) { delete core.animateFrame.asyncId[changeAnimate]; clearInterval(changeAnimate); core.status.curtainColor = color; diff --git a/libs/core.js b/libs/core.js index b00f7a7c..87a51ea2 100644 --- a/libs/core.js +++ b/libs/core.js @@ -921,6 +921,11 @@ core.prototype.setFg = function(color, time, callback) { core.control.setFg(color, time, callback); } +////// 画面闪烁 ////// +core.prototype.screenFlash = function (color, time, times, callback) { + core.ui.screenFlash(color, time, times, callback); +} + ////// 更新全地图显伤 ////// core.prototype.updateDamage = function () { core.control.updateDamage(); diff --git a/libs/events.js b/libs/events.js index f0aa8603..16e5e82e 100644 --- a/libs/events.js +++ b/libs/events.js @@ -822,6 +822,17 @@ events.prototype.doAction = function() { }); } break; + case "screenFlash": // 画面闪烁 + if (data.async) { + core.screenFlash(data.color, data.time, data.times); + this.doAction(); + } + else { + core.screenFlash(data.color, data.time, data.times, function() { + core.events.doAction(); + }); + } + break; case "setWeather": // 更改天气 core.setWeather(data.name, data.level); if (core.isset(data.name)) diff --git a/libs/ui.js b/libs/ui.js index ff35e60d..1fd6bad0 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2833,6 +2833,22 @@ ui.prototype.drawHelp = function () { ]); } +////// 画面闪烁 ////// +ui.prototype.screenFlash = function (color, time, times, callback) { + times = times || 1; + time = time/3; + var nowColor = core.clone(core.status.curtainColor); + core.setFg(color, time, function() { + core.setFg(nowColor, time * 2, function() { + if (times > 1) + core.screenFlash(color, time * 3, times - 1, callback); + else { + if (core.isset(callback)) callback(); + } + }); + }); +} + ////// 动态canvas ////// ////// canvas创建 ////// diff --git a/project/floors/sample0.js b/project/floors/sample0.js index 06e8c93a..c08187bb 100644 --- a/project/floors/sample0.js +++ b/project/floors/sample0.js @@ -27,7 +27,8 @@ main.floors.sample0= "firstArrive": [ { "type": "setText", - "background": "winskin.png" + "background": "winskin.png", + "time": 0 }, "\t[样板提示]首次到达某层可以触发 firstArrive 事件,该事件可类似于RMXP中的“自动执行脚本”。\n\n本事件支持一切的事件类型,常常用来触发对话,例如:", "\t[hero]\b[up,hero]我是谁?我从哪来?我又要到哪去?",