From 8ee28cd26dc66d965a595949feb166e18227a81d Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Tue, 5 May 2020 15:29:01 +0800 Subject: [PATCH] =?UTF-8?q?playBgm=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4;res?= =?UTF-8?q?umeBgm=E4=BB=8E=E6=9A=82=E5=81=9C=E7=82=B9=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 18 ++++++++++-------- libs/control.js | 6 ++++-- libs/core.js | 3 ++- libs/events.js | 4 ++-- v2.x-final更新.txt | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 751e361f..864ccf28 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1361,7 +1361,7 @@ animate_s /* animate_s tooltip : animate:显示动画,位置填hero或者1,2形式的位置,或者不填代表当前事件点 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=animate%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E7%94%BB -default : ["zone","hero",false] +default : ["zone","hero",false,false] colour : this.soundColor if (EvalString_0) { if(MotaActionFunctions.pattern.id2.test(EvalString_0)) { @@ -1665,16 +1665,17 @@ return code; */; playBgm_s - : '播放背景音乐' EvalString '持续到下个本事件' Bool Newline + : '播放背景音乐' EvalString '开始播放秒数' Int '持续到下个本事件' Bool Newline /* playBgm_s tooltip : playBgm: 播放背景音乐 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=playbgm%EF%BC%9A%E6%92%AD%E6%94%BE%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90 -default : ["bgm.mp3", true] +default : ["bgm.mp3", 0, true] colour : this.soundColor +Int_0 = Int_0 ? (', "startTime": '+Int_0) : ''; Bool_0 = Bool_0 ? ', "keep": true' : ''; -var code = '{"type": "playBgm", "name": "'+EvalString_0+'"'+Bool_0+'},\n'; +var code = '{"type": "playBgm", "name": "'+EvalString_0+'"'+Int_0+Bool_0+'},\n'; return code; */; @@ -1691,14 +1692,15 @@ return code; */; resumeBgm_s - : '恢复背景音乐' Newline + : '恢复背景音乐' '从暂停位置继续播放' Bool Newline /* resumeBgm_s tooltip : resumeBgm: 恢复背景音乐 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=resumebgm%EF%BC%9A%E6%81%A2%E5%A4%8D%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90 colour : this.soundColor -var code = '{"type": "resumeBgm"},\n'; +Bool_0 = Bool_0 ? ', "resume": true' : ''; +var code = '{"type": "resumeBgm"' + Bool_0 + '},\n'; return code; */; @@ -3419,7 +3421,7 @@ ActionParser.prototype.parseAction = function() { break; case "playBgm": this.next = MotaActionBlocks['playBgm_s'].xmlText([ - data.name,data.keep||false,this.next]); + data.name,data.startTime||0,data.keep||false,this.next]); break case "pauseBgm": this.next = MotaActionBlocks['pauseBgm_s'].xmlText([ @@ -3427,7 +3429,7 @@ ActionParser.prototype.parseAction = function() { break case "resumeBgm": this.next = MotaActionBlocks['resumeBgm_s'].xmlText([ - this.next]); + data.resume||false,this.next]); break case "loadBgm": this.next = MotaActionBlocks['loadBgm_s'].xmlText([ diff --git a/libs/control.js b/libs/control.js index cfb27aea..c3b81eb7 100644 --- a/libs/control.js +++ b/libs/control.js @@ -2306,6 +2306,7 @@ control.prototype.pauseBgm = function () { if (main.mode!='play')return; try { if (core.musicStatus.playingBgm) { + core.musicStatus.pauseTime = core.material.bgms[core.musicStatus.playingBgm].currentTime; core.material.bgms[core.musicStatus.playingBgm].pause(); core.musicStatus.playingBgm = null; } @@ -2318,10 +2319,11 @@ control.prototype.pauseBgm = function () { } ////// 恢复背景音乐的播放 ////// -control.prototype.resumeBgm = function () { +control.prototype.resumeBgm = function (resumeTime) { if (main.mode!='play')return; try { - core.playBgm(core.musicStatus.playingBgm || core.musicStatus.lastBgm || main.startBgm); + core.playBgm(core.musicStatus.playingBgm || core.musicStatus.lastBgm || main.startBgm, + resumeTime ? core.musicStatus.pauseTime : 0); } catch (e) { console.log("无法恢复BGM"); diff --git a/libs/core.js b/libs/core.js index 7a7340d5..edeb06af 100644 --- a/libs/core.js +++ b/libs/core.js @@ -47,7 +47,7 @@ function core() { 'data': null, 'fog': null, }, - "tip": {}, + "tip": null, "asyncId": {} } this.musicStatus = { @@ -55,6 +55,7 @@ function core() { 'bgmStatus': false, // 是否播放BGM 'soundStatus': true, // 是否播放SE 'playingBgm': null, // 正在播放的BGM + 'pauseTime': 0, // 上次暂停的时间 'lastBgm': null, // 上次播放的bgm 'gainNode': null, 'playingSounds': {}, // 正在播放的SE diff --git a/libs/events.js b/libs/events.js index 2981e5f2..1c498f88 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1572,7 +1572,7 @@ events.prototype._action_insert = function (data, x, y, prefix) { } events.prototype._action_playBgm = function (data, x, y, prefix) { - core.playBgm(data.name); + core.playBgm(data.name, data.startTime || 0); core.setFlag("__bgm__", data.keep ? data.name : null); core.doAction(); } @@ -1583,7 +1583,7 @@ events.prototype._action_pauseBgm = function (data, x, y, prefix) { } events.prototype._action_resumeBgm = function (data, x, y, prefix) { - core.resumeBgm(); + core.resumeBgm(data.resume); core.doAction(); } diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index 9956f0a2..e380d237 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -5,7 +5,7 @@ (已完成!\b[up,null]可实现此效果) 4. 建议显示文章的\b[]提供top和bottom这两种新写法来实现在顶部或底部显示对话框,目前只有startText、firstArrive、eachArrive、useItemEvent和公共事件等没有当前点的事件中才能用up和down来临时实现这种效果,否则就得设置剧情文本的属性,这在频繁来回切换时是致命的,就像《无上之光》RMXP版地上40层一样 5. 建议优化core.splitLines()来避免把单词打断和触犯标点禁则,如点号和右标号禁止用于行首,左标号禁止用于行尾 (已完成!) 6. core.drawAnimate()和对应的事件,建议增加一个boolean型参数来表示坐标是绝对坐标(即当前的实现)还是在视野中的相对坐标(以13*13为例相对坐标总是在0~12之间),以实现形如“在视野正中心播放某某动画”的需求(小地图可以写6,6,大地图怎么办) -7. 建议把core.playBgm(bgm, startTime)的startTime参数在事件中也提供出来,以用于一些演出(比如适当的剧情处直接从高潮开始)。同理可以让“暂停背景音乐”记录下当前播放到了第几秒,并在“恢复背景音乐”中自动从这个秒数恢复。作者还可以手动配合音量渐变效果 +(已完成!) 7. 建议把core.playBgm(bgm, startTime)的startTime参数在事件中也提供出来,以用于一些演出(比如适当的剧情处直接从高潮开始)。同理可以让“暂停背景音乐”记录下当前播放到了第几秒,并在“恢复背景音乐”中自动从这个秒数恢复。作者还可以手动配合音量渐变效果 8. 系统设置菜单中“音量”和“步时”的点击区并不是根据文本长度自动适配的,这导致作者修改文本(包括但不限于翻译)后玩家难以找到准确的点击区,建议优化 9. 建议给“显示选择项”、“显示确认框”、“等待用户操作”这三个事件添加一个“若多少毫秒内不响应则触发的分支”,用来实现一些如新新2的QTE,录像中可以记录“choice: timeout”、“confirm: timeout”和“wait: timeout”来表示触发了超时分支 10. 建议给“转变图块”事件增加一个淡入时间参数,用于原本是空地或空气墙的情况,目前这种效果必须借助存在安全隐患的红点