浏览代码

more fixes to sound fading and a small typo fix in notifySelfArray

tags/v0.7.0^2
Shaun 4 年前
父节点
当前提交
7c7f5cbf63
共有 2 个文件被更改,包括 18 次插入9 次删除
  1. +17
    -8
      src/client/js/sound/sound.js
  2. +1
    -1
      src/server/components/social.js

+ 17
- 8
src/client/js/sound/sound.js 查看文件

@@ -14,13 +14,15 @@ define([
const globalScopes = ['ui'];
const minDistance = 10;
const globalVolume = 0.3;
const fadeDuration = 3000;
const fadeDuration = 1800;

return {
sounds: [],

muted: false,

currentMusic: null,

init: function () {
events.on('onToggleAudio', this.onToggleAudio.bind(this));
events.on('onPlaySound', this.playSound.bind(this));
@@ -85,7 +87,7 @@ define([

sound.volume(volume);
} else {
sound.volume(1);
sound.volume(volume);
sound.play();
}
},
@@ -101,12 +103,17 @@ define([
return;
}

if (sound.playing())
if (!sound.playing()) {
sound.volume(0);
sound.play();
}

if (this.currentMusic === soundEntry)
return;

sound.volume(0);
sound.play();
sound.fade(0, globalVolume, fadeDuration);
this.currentMusic = soundEntry;
sound.fade(sound.volume(), globalVolume, fadeDuration);
},

stopSoundHelper: function (soundEntry) {
@@ -117,8 +124,10 @@ define([

if (music)
sound.fade(sound.volume(), 0, fadeDuration);
else
else {
sound.stop();
sound.volume(0);
}
},

updateSounds: function (playerX, playerY) {
@@ -161,7 +170,7 @@ define([
if (defaultMusic)
this.playMusicHelper(defaultMusic);

const activeMusic = sounds.filter(s => s.music && s !== defaultMusic && s.sound && s.sound.playing());
const activeMusic = sounds.filter(s => s.music && s !== defaultMusic);
activeMusic.forEach(s => this.stopSoundHelper(s));
} else {
if (defaultMusic)


+ 1
- 1
src/server/components/social.js 查看文件

@@ -418,7 +418,7 @@ module.exports = {
const { obj: { id, serverId, instance: { syncer } } } = this;

messages.forEach(m => {
const { className = 'color-redA', type = 'info ' } = m;
const { className = 'color-redA', type = 'info' } = m;
m.className = className;
m.type = type;
});


正在加载...
取消
保存