画面振动增强 & 自绘setFilter
This commit is contained in:
parent
801d6cd2a8
commit
b278306b3e
@ -1192,10 +1192,13 @@ unregisterSystemEvent: fn(type: string)
|
||||
useFly: fn(fromUserAction?: bool)
|
||||
点击楼层传送器时的打开操作
|
||||
|
||||
vibrate: fn(time?: number, callback?: fn())
|
||||
视野左右抖动
|
||||
vibrate: fn(direction?: string, time?: number, speed?: number, power?: number, callback?: fn())
|
||||
视野抖动
|
||||
例如:core.vibrate(); // 视野左右抖动1秒
|
||||
time: 抖动时长,单位为毫秒。必须为半秒的倍数,不填或小于1秒都视为1秒
|
||||
direction: 抖动方向;可填 horizontal(左右),vertical(上下),diagonal1(左上右下),diagonal2(左下右上)
|
||||
time: 抖动时长,单位为毫秒
|
||||
speed: 抖动速度
|
||||
power: 抖动幅度
|
||||
callback: 抖动平息后的回调函数,可选
|
||||
|
||||
visitFloor: fn(floorId?: string)
|
||||
|
||||
@ -451,8 +451,8 @@ core.insertAction({"type": "changeFloor", "floorId": "MT" + core.rand2(20)})
|
||||
|
||||
这个类别的指令会负责动画、视角、色调、天气、音频等其他一些细节。
|
||||
|
||||
1. **画面震动:**会让画面左右震动,时间必须为500毫秒的倍数且至少1秒。
|
||||
* 实际执行`core.vibrate(time, callback)`函数。
|
||||
1. **画面震动:**会让画面左右震动。
|
||||
* 实际执行`core.vibrate(direction, time, speed, pwoer, callback)`函数。
|
||||
2. **显示动画:**如题,可以双击选文件并预览(预览的坐标锁定为视野中心)和试听/修改音效。
|
||||
* 如需从地图选点请右击指令块,坐标也可写hero令动画跟随勇士移动。
|
||||
* 坐标不写则取当前点,如果勾选“相对窗口坐标”则坐标应填写为0—12或0—14表示视野中的相对坐标(如13×13样板填两个6表示视野中心)。
|
||||
|
||||
@ -3757,8 +3757,8 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
|
||||
"!type": "fn(data?: ?)"
|
||||
},
|
||||
"vibrate": {
|
||||
"!doc": "视野左右抖动<br/>例如:core.vibrate(); // 视野左右抖动1秒<br/>time: 抖动时长,单位为毫秒。必须为半秒的倍数,不填或小于1秒都视为1秒<br/>callback: 抖动平息后的回调函数,可选",
|
||||
"!type": "fn(time?: number, callback?: fn())"
|
||||
"!doc": "视野抖动<br/>例如:core.vibrate(); // 视野抖动1秒<br/>direction: 抖动方向;可填 horizontal(左右),vertical(上下),diagonal1(左上右下),diagonal2(左下右上)<br/>time: 抖动时长<br/>speed: 抖动速度<br/>power: 抖动幅度<br/>callback: 抖动平息后的回调函数,可选",
|
||||
"!type": "fn(direction?: string, time?: number, speed?: number, power?: number, callback?: fn())"
|
||||
},
|
||||
"confirmRestart": {
|
||||
"!doc": "询问是否需要重新开始",
|
||||
|
||||
@ -865,6 +865,7 @@ action
|
||||
| previewUI_s
|
||||
| clearMap_s
|
||||
| setAttribute_s
|
||||
| setFilter_s
|
||||
| fillText_s
|
||||
| fillBoldText_s
|
||||
| drawTextContent_s
|
||||
@ -2093,17 +2094,16 @@ return code;
|
||||
*/;
|
||||
|
||||
vibrate_s
|
||||
: '画面震动' '时间' Int '不等待执行完毕' Bool Newline
|
||||
: '画面震动' '方向' Vibrate_List '时间' Int '速度' Int '振幅' Int '不等待执行完毕' Bool Newline
|
||||
|
||||
|
||||
/* vibrate_s
|
||||
tooltip : vibrate: 画面震动
|
||||
helpUrl : /_docs/#/instruction
|
||||
default : [2000,false]
|
||||
default : ["horizontal",2000,10,10,false]
|
||||
colour : this.soundColor
|
||||
Int_0 = Int_0 ?(', "time": '+Int_0):'';
|
||||
var async = Bool_0?', "async": true':''
|
||||
var code = '{"type": "vibrate"' + Int_0 + async + '},\n';
|
||||
var code = '{"type": "vibrate", "direction": "'+Vibrate_List_0+'", "time": '+Int_0+', "speed": '+Int_1+', "power": '+Int_2+async+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
@ -3170,6 +3170,26 @@ var code = '{"type": "setAttribute"'+FontString_0+ColorString_0+ColorString_1+In
|
||||
return code;
|
||||
*/;
|
||||
|
||||
|
||||
setFilter_s
|
||||
: '设置画布特效' '虚化' Number '色相' Int '灰度' Number '反色' Bool '阴影' Number Newline
|
||||
|
||||
|
||||
/* setFilter_s
|
||||
tooltip : setFilter: 设置画布特效
|
||||
helpUrl : /_docs/#/instruction
|
||||
default : [0,0,0,false,0]
|
||||
previewBlock : true
|
||||
colour : this.uiColor
|
||||
if (Number_0 < 0) throw '虚化不得小于0;0为完全没有虚化';
|
||||
if (Int_0 < 0 || Int_0 >= 360) throw '色相需要在0~359之间';
|
||||
if (Number_1 < 0 || Number_1 > 1) throw '灰度需要在0~1之间';
|
||||
if (Number_2 < 0) throw '阴影不得小于0;0为完全没有阴影';
|
||||
var code = '{"type": "setFilter", "blur": '+Number_0+', "hue": '+Int_0+', "grayscale": '+Number_1+', "invert": '+Bool_0+', "shadow": '+Number_2+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
|
||||
fillText_s
|
||||
: '绘制文本' 'x' PosString 'y' PosString '样式' ColorString? Colour '字体' FontString? '最大宽度' IntString? BGNL? EvalString Newline
|
||||
|
||||
@ -3983,6 +4003,10 @@ EquipValueType_List
|
||||
: '数值项'|'百分比项'
|
||||
/*EquipValueType_List ['value','percentage']*/;
|
||||
|
||||
Vibrate_List
|
||||
: '左右'|'上下'|'左上-右下'|'左下-右上'
|
||||
/*Vibrate_List ['horizontal','vertical','diagonal1','diagonal2']*/;
|
||||
|
||||
Colour
|
||||
: 'sdeirughvuiyasdeb'+ //为了被识别为复杂词法规则
|
||||
;
|
||||
|
||||
@ -550,7 +550,8 @@ ActionParser.prototype.parseAction = function() {
|
||||
}
|
||||
break;
|
||||
case "vibrate": // 画面震动
|
||||
this.next = MotaActionBlocks['vibrate_s'].xmlText([data.time||0, data.async||false, this.next]);
|
||||
this.next = MotaActionBlocks['vibrate_s'].xmlText([data.direction||'horizontal',
|
||||
data.time||0, data.speed, data.power, data.async||false, this.next]);
|
||||
break;
|
||||
case "showImage": // 显示图片
|
||||
data.loc=data.loc||['','']
|
||||
@ -954,6 +955,10 @@ ActionParser.prototype.parseAction = function() {
|
||||
data.font,data.fillStyle,'rgba('+data.fillStyle+')',data.strokeStyle,'rgba('+data.strokeStyle+')',
|
||||
data.lineWidth,data.alpha,data.align,data.baseline,data.z,this.next]);
|
||||
break;
|
||||
case "setFilter":
|
||||
this.next = MotaActionBlocks['setFilter_s'].xmlText([
|
||||
data.blur, data.hue, data.grayscale, data.invert||false, data.shadow, this.next]);
|
||||
break;
|
||||
case "fillText": // 绘制一行文本
|
||||
data.style = this.Colour(data.style);
|
||||
this.next = MotaActionBlocks['fillText_s'].xmlText([
|
||||
|
||||
@ -227,6 +227,7 @@ editor_blocklyconfig=(function(){
|
||||
MotaActionBlocks['previewUI_s'].xmlText(),
|
||||
MotaActionBlocks['clearMap_s'].xmlText(),
|
||||
MotaActionBlocks['setAttribute_s'].xmlText(),
|
||||
MotaActionBlocks['setFilter_s'].xmlText(),
|
||||
MotaActionBlocks['fillText_s'].xmlText(),
|
||||
MotaActionBlocks['fillBoldText_s'].xmlText(),
|
||||
MotaActionBlocks['drawTextContent_s'].xmlText(),
|
||||
|
||||
@ -374,6 +374,7 @@ editor_ui_wrapper = function (editor) {
|
||||
uievent.drawPreviewUI = function () {
|
||||
core.setAlpha('uievent', 1);
|
||||
core.clearMap('uievent');
|
||||
core.setFilter('uievent', null);
|
||||
|
||||
// 绘制UI
|
||||
var background = uievent.elements.selectBackground.value;
|
||||
|
||||
@ -1072,9 +1072,10 @@ events.prototype.checkAutoEvents = function () {
|
||||
var todo = [], delay = [];
|
||||
core.status.autoEvents.forEach(function (autoEvent) {
|
||||
var symbol = autoEvent.symbol, x = autoEvent.x, y = autoEvent.y, floorId = autoEvent.floorId;
|
||||
// 不在当前楼层 or 已经执行过 or 正在执行中
|
||||
// 不在当前楼层 or 已经执行过 or 已被分区 or 正在执行中
|
||||
if (autoEvent.currentFloor && floorId != core.status.floorId) return;
|
||||
if (!autoEvent.multiExecute && core.autoEventExecuted(symbol)) return;
|
||||
if ((flags.__removed__||[]).indexOf(floorId) >= 0) return;
|
||||
if (core.autoEventExecuting(symbol)) return;
|
||||
var prefix = floorId + "@" + x + "@" + y;
|
||||
try {
|
||||
@ -2262,7 +2263,7 @@ events.prototype._action_hideHero = function (data, x, y, prefix) {
|
||||
}
|
||||
|
||||
events.prototype._action_vibrate = function (data, x, y, prefix) {
|
||||
this.__action_doAsyncFunc(data.async, core.vibrate, data.time);
|
||||
this.__action_doAsyncFunc(data.async, core.vibrate, data.direction, data.time, data.speed, data.power);
|
||||
}
|
||||
|
||||
events.prototype._action_sleep = function (data, x, y, prefix) {
|
||||
@ -2537,6 +2538,10 @@ events.prototype._action_setAttribute = function (data, x, y, prefix) {
|
||||
this.__action_doUIEvent(data);
|
||||
}
|
||||
|
||||
events.prototype._action_setFilter = function (data, x, y, prefix) {
|
||||
this.__action_doUIEvent(data);
|
||||
}
|
||||
|
||||
events.prototype._action_drawImage = function (data, x, y, prefix) {
|
||||
this.__action_doUIEvent(data);
|
||||
}
|
||||
@ -3125,41 +3130,45 @@ events.prototype.setVolume = function (value, time, callback) {
|
||||
}
|
||||
|
||||
////// 画面震动 //////
|
||||
events.prototype.vibrate = function (time, callback) {
|
||||
events.prototype.vibrate = function (direction, time, speed, power, callback) {
|
||||
if (core.isReplaying()) {
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
if (!time || time < 1000) time = 1000;
|
||||
// --- 将time调整为500的倍数(上整),不然会出错
|
||||
time /= Math.max(core.status.replay.speed, 1)
|
||||
time = Math.ceil(time / 500) * 500;
|
||||
var shakeInfo = {duration: time * 3 / 50, speed: 5, power: 5, direction: 1, shake: 0};
|
||||
if (!time) time = 1000;
|
||||
speed = speed || 10;
|
||||
power = power || 10;
|
||||
var shakeInfo = {duration: parseInt(time / 10), speed: speed, power: power, direction: 1, shake: 0};
|
||||
var animate = setInterval(function () {
|
||||
core.events._vibrate_update(shakeInfo);
|
||||
core.control.addGameCanvasTranslate(shakeInfo.shake, 0);
|
||||
if (shakeInfo.duration === 0) {
|
||||
switch (direction) {
|
||||
case 'vertical': core.addGameCanvasTranslate(0, shakeInfo.shake); break;
|
||||
case 'diagonal1': core.addGameCanvasTranslate(shakeInfo.shake, shakeInfo.shake); break;
|
||||
case 'diagonal2': core.addGameCanvasTranslate(-shakeInfo.shake, shakeInfo.shake); break;
|
||||
default: core.addGameCanvasTranslate(shakeInfo.shake, 0);
|
||||
}
|
||||
if (shakeInfo.duration === 0 && shakeInfo.shake == 0) {
|
||||
delete core.animateFrame.asyncId[animate];
|
||||
clearInterval(animate);
|
||||
if (callback) callback();
|
||||
}
|
||||
}, 50 / 3);
|
||||
}, 10);
|
||||
|
||||
core.animateFrame.asyncId[animate] = true;
|
||||
}
|
||||
|
||||
events.prototype._vibrate_update = function (shakeInfo) {
|
||||
if (shakeInfo.duration >= 1 || shakeInfo.shake != 0) {
|
||||
var delta = (shakeInfo.power * shakeInfo.speed * shakeInfo.direction) / 10.0;
|
||||
var delta = shakeInfo.speed * shakeInfo.direction / 6;
|
||||
if (shakeInfo.duration <= 1 && shakeInfo.shake * (shakeInfo.shake + delta) < 0) {
|
||||
shakeInfo.shake = 0;
|
||||
} else {
|
||||
shakeInfo.shake += delta;
|
||||
}
|
||||
if (shakeInfo.shake > shakeInfo.power * 2) {
|
||||
if (shakeInfo.shake > shakeInfo.power) {
|
||||
shakeInfo.direction = -1;
|
||||
}
|
||||
if (shakeInfo.shake < -shakeInfo.power * 2) {
|
||||
if (shakeInfo.shake < -shakeInfo.power) {
|
||||
shakeInfo.direction = 1;
|
||||
}
|
||||
if (shakeInfo.duration >= 1) {
|
||||
|
||||
@ -521,6 +521,11 @@ ui.prototype._uievent_setAttribute = function (data) {
|
||||
}
|
||||
}
|
||||
|
||||
ui.prototype._uievent_setFilter = function (data) {
|
||||
this._createUIEvent();
|
||||
this.setFilter('uievent',data);
|
||||
}
|
||||
|
||||
////// 计算某段文字的宽度 //////
|
||||
ui.prototype.calWidth = function (name, text, font) {
|
||||
var ctx = this.getContextByName(name);
|
||||
|
||||
@ -1345,8 +1345,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
else if (step <= 12) core.drawHero('midFoot', 4 * o * (step - 8));
|
||||
else if (step <= 16) core.drawHero('rightFoot', 4 * o * (step - 8)); // if (step == 8) {
|
||||
if (step == 8 || step == 16) {
|
||||
core.setHeroLoc('x', x + o * core.utils.scan[direction].x, true);
|
||||
core.setHeroLoc('y', y + o * core.utils.scan[direction].y, true);
|
||||
core.setHeroLoc('x', x + o * core.utils.scan2[direction].x, true);
|
||||
core.setHeroLoc('y', y + o * core.utils.scan2[direction].y, true);
|
||||
core.updateFollowers();
|
||||
curr[1]--;
|
||||
if (curr[1] <= 0) moveSteps.shift();
|
||||
|
||||
9
runtime.d.ts
vendored
9
runtime.d.ts
vendored
@ -1005,12 +1005,15 @@ declare class events {
|
||||
setVolume(value: number, time?: number, callback?: () => void): void
|
||||
|
||||
/**
|
||||
* 视野左右抖动
|
||||
* 视野抖动
|
||||
* @example core.vibrate(); // 视野左右抖动1秒
|
||||
* @param time 抖动时长,单位为毫秒。必须为半秒的倍数,不填或小于1秒都视为1秒
|
||||
* @param direction 抖动方向
|
||||
* @param time 抖动时长,单位为毫秒
|
||||
* @param speed 抖动速度
|
||||
* @param power 抖动幅度
|
||||
* @param callback 抖动平息后的回调函数,可选
|
||||
*/
|
||||
vibrate(time?: number, callback?: () => void): void
|
||||
vibrate(direction?: string, time?: number, speed?: number, power?: number, callback?: () => void): void
|
||||
|
||||
/**
|
||||
* 强制移动主角(包括后退),这个函数的作者已经看不懂这个函数了
|
||||
|
||||
Loading…
Reference in New Issue
Block a user