show/hideHero with time
This commit is contained in:
parent
91e4e40fc0
commit
1567b736e1
@ -1123,26 +1123,32 @@ return code;
|
||||
*/;
|
||||
|
||||
showHero_s
|
||||
: '显示勇士' Newline
|
||||
: '显示勇士' '动画时间' IntString? '不等待执行完毕' Bool Newline
|
||||
|
||||
|
||||
/* showHero_s
|
||||
tooltip : showHero: 显示勇士
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showHero%3a+%e6%98%be%e7%a4%ba%e5%8b%87%e5%a3%ab
|
||||
default : ['',false]
|
||||
colour : this.soundColor
|
||||
var code = '{"type": "showHero"},\n';
|
||||
IntString_0 = IntString_0 && (', "time": ' + IntString_0);
|
||||
Bool_0 = Bool_0 ? (', "async": true') : '';
|
||||
var code = '{"type": "showHero"'+IntString_0+Bool_0+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
hideHero_s
|
||||
: '隐藏勇士' Newline
|
||||
: '隐藏勇士' '动画时间' IntString? '不等待执行完毕' Bool Newline
|
||||
|
||||
|
||||
/* hideHero_s
|
||||
tooltip : hideHero: 隐藏勇士
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=hideHero%ef%bc%9a%e9%9a%90%e8%97%8f%e5%8b%87%e5%a3%ab
|
||||
default : ['',false]
|
||||
colour : this.soundColor
|
||||
var code = '{"type": "hideHero"},\n';
|
||||
IntString_0 = IntString_0 && (', "time": ' + IntString_0);
|
||||
Bool_0 = Bool_0 ? (', "async": true') : '';
|
||||
var code = '{"type": "hideHero"'+IntString_0+Bool_0+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
|
||||
@ -654,11 +654,11 @@ ActionParser.prototype.parseAction = function() {
|
||||
break;
|
||||
case "showHero":
|
||||
this.next = MotaActionBlocks['showHero_s'].xmlText([
|
||||
this.next]);
|
||||
data.time, data.async||false, this.next]);
|
||||
break;
|
||||
case "hideHero":
|
||||
this.next = MotaActionBlocks['hideHero_s'].xmlText([
|
||||
this.next]);
|
||||
data.time, data.async||false, this.next]);
|
||||
break;
|
||||
case "sleep": // 等待多少毫秒
|
||||
this.next = MotaActionBlocks['sleep_s'].xmlText([
|
||||
|
||||
@ -783,17 +783,61 @@ control.prototype.drawHero = function (status, offset) {
|
||||
core.status.heroCenter.py = 32 * y + offsetY + 32 - core.material.icons.hero.height / 2;
|
||||
|
||||
if (!core.hasFlag('hideHero')) {
|
||||
this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) {
|
||||
core.drawImage('hero', block.img, block.heroIcon[block.status]*block.width,
|
||||
block.heroIcon.loc * block.height, block.width, block.height,
|
||||
block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height);
|
||||
});
|
||||
this._drawHero_draw(direction, x, y, status, offset);
|
||||
}
|
||||
|
||||
core.control.updateViewport();
|
||||
core.setGameCanvasTranslate('hero', 0, 0);
|
||||
}
|
||||
|
||||
control.prototype._drawHero_draw = function (direction, x, y, status, offset) {
|
||||
this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) {
|
||||
core.drawImage('hero', block.img, block.heroIcon[block.status]*block.width,
|
||||
block.heroIcon.loc * block.height, block.width, block.height,
|
||||
block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height);
|
||||
});
|
||||
}
|
||||
|
||||
control.prototype.triggerHero = function (type, time, callback) {
|
||||
if (type == null) {
|
||||
type = core.hasFlag('hideHero') ? 'show' : 'hide';
|
||||
}
|
||||
if ((core.hasFlag('hideHero') && type != 'show') || (!core.hasFlag('hideHero') && type != 'hide')) {
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
if (type == 'show') core.removeFlag('hideHero');
|
||||
else core.setFlag('hideHero', true);
|
||||
|
||||
time = time || 0;
|
||||
if (time == 0) {
|
||||
core.drawHero();
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
time /= Math.max(core.status.replay.speed, 1)
|
||||
this._triggerHero_animate(type, 10 / time, callback);
|
||||
}
|
||||
|
||||
control.prototype._triggerHero_animate = function (type, delta, callback) {
|
||||
var opacity = type != 'show' ? 1 : 0;
|
||||
var animate = setInterval(function () {
|
||||
opacity += type != 'show' ? -delta : delta;
|
||||
core.clearMap('hero');
|
||||
core.setAlpha('hero', opacity);
|
||||
core.control._drawHero_draw(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop', 0);
|
||||
core.setAlpha('hero', 1);
|
||||
if (opacity >= 1 || opacity <= 0) {
|
||||
delete core.animateFrame.asyncId[animate];
|
||||
clearInterval(animate);
|
||||
core.drawHero();
|
||||
if (callback) callback();
|
||||
}
|
||||
}, 10);
|
||||
|
||||
core.animateFrame.asyncId[animate] = true;
|
||||
}
|
||||
|
||||
control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) {
|
||||
var heroIconArr = core.material.icons.hero, drawObjs = [], index = 0;
|
||||
drawObjs.push({
|
||||
|
||||
@ -2011,15 +2011,25 @@ events.prototype._action_hideStatusBar = function (data, x, y, prefix) {
|
||||
}
|
||||
|
||||
events.prototype._action_showHero = function (data, x, y, prefix) {
|
||||
core.removeFlag('hideHero');
|
||||
core.drawHero();
|
||||
core.doAction();
|
||||
data.time = data.time || 0;
|
||||
if (data.time > 0) {
|
||||
this.__action_doAsyncFunc(data.async, core.triggerHero, 'show', data.time);
|
||||
} else {
|
||||
core.removeFlag('hideHero');
|
||||
core.drawHero();
|
||||
core.doAction();
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype._action_hideHero = function (data, x, y, prefix) {
|
||||
core.setFlag('hideHero', true);
|
||||
core.drawHero();
|
||||
core.doAction();
|
||||
data.time = data.time || 0;
|
||||
if (data.time > 0) {
|
||||
this.__action_doAsyncFunc(data.async, core.triggerHero, 'hide', data.time);
|
||||
} else {
|
||||
core.setFlag('hideHero', true);
|
||||
core.drawHero();
|
||||
core.doAction();
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype._action_vibrate = function (data, x, y, prefix) {
|
||||
|
||||
@ -135,7 +135,7 @@
|
||||
(不处理) 67. “画面震动”事件希望不要光左右晃,至少做成QQ窗口抖动的效果吧w
|
||||
(不处理) 68. “自动存档”事件希望加一个“读此档后打断当前事件”的勾选项,否则这种自动存档用于强制战斗之前就没什么意义了,读了档还是会强制战斗。录像兼容性方面,不知道如果这种自动存档只用于事件开头是不是就不会有问题
|
||||
(已修复!) 69. “等待用户操作”虽然提供了场合块但还不支持将多个按键的场合合并(比如空格、回车和C键一般会被作者予以合并,执行内容如果只是大致相同也值得合并,在块内再行分歧),希望支持一下
|
||||
70. “显隐勇士”事件指令希望加个淡入淡出时间参数
|
||||
(已完成!) 70. “显隐勇士”事件指令希望加个淡入淡出时间参数
|
||||
(不处理,请用等待事件) 1. 希望给core.drawTip()和core.playSound()出个同步版本,目前只有异步版本,后者如果要模拟同步就得绑在一个透明动画上
|
||||
(已完成!) 72. “绘制描边文本”事件希望加一个“描边颜色”参数,目前只能描黑边
|
||||
(已完成!) 73. 画弧既然有现成的API,那建议也作为UI绘制事件提供。甚至希望提供画椭圆功能(长短轴水平或铅直的那种)参数为中心坐标和长短轴长度
|
||||
|
||||
Loading…
Reference in New Issue
Block a user