setFg based screenFlash
This commit is contained in:
parent
c7f30538d8
commit
e7641303dc
@ -1157,12 +1157,12 @@ return code;
|
||||
*/;
|
||||
|
||||
screenFlash_s
|
||||
: '画面闪烁' Number ',' Number ',' Number '强度' Number '动画时间' Int '不等待执行完毕' Bool Newline
|
||||
: '画面闪烁' Number ',' Number ',' Number '强度' Number '单次时间' Int '执行次数' Int? '不等待执行完毕' Bool Newline
|
||||
|
||||
/* screenFlash_s
|
||||
tooltip : screenFlash: 更改画面色调,动画时间可不填
|
||||
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,100,500,false]
|
||||
default : [255,255,255,1,500,1,false]
|
||||
colour : this.soundColor
|
||||
var limit = function(v,min,max) {
|
||||
if(v>max) return max;
|
||||
@ -1172,9 +1172,10 @@ var limit = function(v,min,max) {
|
||||
Number_0 = limit(Number_0,0,255);
|
||||
Number_1 = limit(Number_1,0,255);
|
||||
Number_2 = limit(Number_2,0,255);
|
||||
Number_3 = limit(Number_3,0,100);
|
||||
Number_3 = limit(Number_3,0,1);
|
||||
Int_1 = Int_1!=='' ?(', "times": '+Int_1):'';
|
||||
var async = Bool_0?', "async": true':'';
|
||||
var code = '{"type": "screenFlash", "color": ['+Number_0+','+Number_1+','+Number_2+'], "intensity": '+Number_3+', "time": '+Int_0 +async+'},\n';
|
||||
var code = '{"type": "screenFlash", "color": ['+Number_0+','+Number_1+','+Number_2+','+Number_3+'], "time": '+Int_0 +Int_1+async+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
@ -2165,7 +2166,7 @@ ActionParser.prototype.parseAction = function() {
|
||||
break;
|
||||
case "screenFlash": // 画面闪烁
|
||||
this.next = MotaActionBlocks['screenFlash_s'].xmlText([
|
||||
data.color[0],data.color[1],data.color[2],data.intensity||100,data.time||500,data.async||false,this.next]);
|
||||
data.color[0],data.color[1],data.color[2],data.color[3]||1,data.time||500,data.times||1,data.async||false,this.next]);
|
||||
break;
|
||||
case "setWeather": // 更改天气
|
||||
this.next = MotaActionBlocks['setWeather_s'].xmlText([
|
||||
|
||||
@ -1067,17 +1067,19 @@ async可选,如果为true则会异步执行(即不等待当前事件执行
|
||||
|
||||
``` js
|
||||
"x,y": [ // 实际执行的事件列表
|
||||
{"type": "screenFlash", "color": [255,255,255], "intensity": 60, "time": 500}, // 闪光为白色,强度为60,动画时间1000毫秒
|
||||
{"type": "screenFlash", "color": [255,0,0], "intensity": 100, "time": 100,"async": true}, // 闪光为红色,强度最大,动画时间100毫秒,且异步执行
|
||||
{"type": "screenFlash", "color": [255,255,255,0.6], "time": 500, "times": 1}, // 闪光为白色,不透明度0.6,动画时间1000毫秒
|
||||
{"type": "screenFlash", "color": [255,0,0,1], "time": 100, "times": 2, "async": true}, // 闪光为红色,强度最大,动画时间100毫秒,闪烁两次且异步执行
|
||||
]
|
||||
```
|
||||
|
||||
color为闪光的颜色。它是一个数组,分别指定目标颜色的R,G,B值。
|
||||
color为闪光的颜色。它是一个数组,分别指定目标颜色的R,G,B,A值。
|
||||
- 常见RGB颜色: 纯黑[0,0,0],纯白[255,255,255],纯红[255,0,0],等等。
|
||||
intensity为强度,即闪光的不透明度,为一个0到100之间的数,值越高闪烁效果越强。默认为100
|
||||
A即闪光的不透明度,为一个0到1之间的数,值越高闪烁效果越强。默认为1
|
||||
|
||||
time为闪烁时间,默认值为500
|
||||
|
||||
times为闪烁次数,两次闪烁会连续进行,默认值为1
|
||||
|
||||
async可选,如果为true则会异步执行(即不等待当前事件执行完毕,立刻执行下一个事件)。
|
||||
|
||||
### setWeather:更改天气
|
||||
|
||||
@ -909,8 +909,8 @@ core.prototype.setFg = function(color, time, callback) {
|
||||
}
|
||||
|
||||
////// 画面闪烁 //////
|
||||
core.prototype.screenFlash = function (color, intensity, time, callback) {
|
||||
core.ui.screenFlash(color, intensity, time, callback);
|
||||
core.prototype.screenFlash = function (color, time, times, callback) {
|
||||
core.ui.screenFlash(color, time, times, callback);
|
||||
}
|
||||
|
||||
////// 更新全地图显伤 //////
|
||||
|
||||
@ -824,11 +824,11 @@ events.prototype.doAction = function() {
|
||||
break;
|
||||
case "screenFlash": // 画面闪烁
|
||||
if (data.async) {
|
||||
core.screenFlash(data.color, data.intensity, data.time);
|
||||
core.screenFlash(data.color, data.time, data.times);
|
||||
this.doAction();
|
||||
}
|
||||
else {
|
||||
core.screenFlash(data.color, data.intensity, data.time, function() {
|
||||
core.screenFlash(data.color, data.time, data.times, function() {
|
||||
core.events.doAction();
|
||||
});
|
||||
}
|
||||
|
||||
32
libs/ui.js
32
libs/ui.js
@ -2770,25 +2770,19 @@ ui.prototype.drawHelp = function () {
|
||||
}
|
||||
|
||||
////// 画面闪烁 //////
|
||||
ui.prototype.screenFlash = function (color, intensity, time, callback) {
|
||||
core.ui.createCanvas("screenFlash", 0, 0, 416, 416, 155);
|
||||
core.dymCanvas.screenFlash.fillStyle = core.arrayToRGB(color);
|
||||
core.dymCanvas.screenFlash.fillRect(0, 0, 416, 416);
|
||||
core.dymCanvas.screenFlash.canvas.style.opacity = intensity / 100;
|
||||
var per_time = 10, step = parseInt(time/per_time);
|
||||
var changeAnimate = setInterval(function(){
|
||||
core.dymCanvas.screenFlash.canvas.style.opacity *= (step-1)/step;
|
||||
step--;
|
||||
if (step <= 0) {
|
||||
clearInterval(changeAnimate);
|
||||
core.ui.deleteCanvas("screenFlash");
|
||||
delete core.animateFrame.asyncId[changeAnimate];
|
||||
// core.status.replay.animate=false;
|
||||
if (core.isset(callback)) callback();
|
||||
}
|
||||
}, per_time);
|
||||
|
||||
core.animateFrame.asyncId[changeAnimate] = true;
|
||||
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 //////
|
||||
|
||||
Loading…
Reference in New Issue
Block a user