Merge pull request #421 from InstantMeteor/v2.x
Added volume control, changed moveSpeed switch.
This commit is contained in:
commit
0b866842dd
@ -823,6 +823,13 @@ actions.prototype._selectChoices = function (length, keycode, callback) {
|
|||||||
if (keycode == 13 || keycode == 32 || keycode == 67) {
|
if (keycode == 13 || keycode == 32 || keycode == 67) {
|
||||||
callback.apply(this, [this.HSIZE, topIndex + core.status.event.selection]);
|
callback.apply(this, [this.HSIZE, topIndex + core.status.event.selection]);
|
||||||
}
|
}
|
||||||
|
//左右方向键调整 音量 行走速度
|
||||||
|
if(core.status.event.id == "switchs" && (core.status.event.selection == 2 || core.status.event.selection == 3))
|
||||||
|
{
|
||||||
|
if (keycode == 37) callback.apply(this, [this.HSIZE - 2, topIndex + core.status.event.selection]);
|
||||||
|
if (keycode == 39) callback.apply(this, [this.HSIZE + 2, topIndex + core.status.event.selection]);
|
||||||
|
}
|
||||||
|
|
||||||
if (keycode >= 49 && keycode <= 57) {
|
if (keycode >= 49 && keycode <= 57) {
|
||||||
var index = keycode - 49;
|
var index = keycode - 49;
|
||||||
if (index < length) {
|
if (index < length) {
|
||||||
@ -1910,11 +1917,11 @@ actions.prototype._keyUpSL = function (keycode) {
|
|||||||
|
|
||||||
////// 系统设置界面时的点击操作 //////
|
////// 系统设置界面时的点击操作 //////
|
||||||
actions.prototype._clickSwitchs = function (x, y) {
|
actions.prototype._clickSwitchs = function (x, y) {
|
||||||
if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return;
|
|
||||||
var choices = core.status.event.ui.choices;
|
var choices = core.status.event.ui.choices;
|
||||||
var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0);
|
var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0);
|
||||||
if (y >= topIndex && y < topIndex + choices.length) {
|
var selection = y - topIndex;
|
||||||
var selection = y - topIndex;
|
if ((x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) && (x != this.HSIZE-2 && selection != 2) && (x != this.HSIZE+2 && selection != 2) && (x != this.HSIZE-2 && selection != 3) && (x != this.HSIZE+2 && selection != 3)) return;
|
||||||
|
if (selection >= 0 && selection < choices.length) {
|
||||||
core.status.event.selection = selection;
|
core.status.event.selection = selection;
|
||||||
switch (selection) {
|
switch (selection) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -1922,18 +1929,24 @@ actions.prototype._clickSwitchs = function (x, y) {
|
|||||||
case 1:
|
case 1:
|
||||||
return this._clickSwitchs_sound();
|
return this._clickSwitchs_sound();
|
||||||
case 2:
|
case 2:
|
||||||
return this._clickSwitchs_moveSpeed();
|
if (x == this.HSIZE-2) { return this._clickSwitchs_userVolume(-0.1); }
|
||||||
|
else if (x == this.HSIZE+2) { return this._clickSwitchs_userVolume(0.1); }
|
||||||
|
return;
|
||||||
case 3:
|
case 3:
|
||||||
return this._clickSwitchs_displayEnemyDamage();
|
if (x == this.HSIZE-2) { return this._clickSwitchs_moveSpeed(-10); }
|
||||||
|
else if (x == this.HSIZE+2) { return this._clickSwitchs_moveSpeed(10); }
|
||||||
|
return;
|
||||||
case 4:
|
case 4:
|
||||||
return this._clickSwitchs_displayCritical();
|
return this._clickSwitchs_displayEnemyDamage();
|
||||||
case 5:
|
case 5:
|
||||||
return this._clickSwitchs_displayExtraDamage();
|
return this._clickSwitchs_displayCritical();
|
||||||
case 6:
|
case 6:
|
||||||
return this._clickSwitchs_localForage();
|
return this._clickSwitchs_displayExtraDamage();
|
||||||
case 7:
|
case 7:
|
||||||
return this._clickSwitchs_clickMove();
|
return this._clickSwitchs_localForage();
|
||||||
case 8:
|
case 8:
|
||||||
|
return this._clickSwitchs_clickMove();
|
||||||
|
case 9:
|
||||||
core.status.event.selection = 0;
|
core.status.event.selection = 0;
|
||||||
core.ui.drawSettings();
|
core.ui.drawSettings();
|
||||||
break;
|
break;
|
||||||
@ -1952,16 +1965,25 @@ actions.prototype._clickSwitchs_sound = function () {
|
|||||||
core.ui.drawSwitchs();
|
core.ui.drawSwitchs();
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.prototype._clickSwitchs_moveSpeed = function () {
|
actions.prototype._clickSwitchs_userVolume = function (delta) {
|
||||||
core.myprompt("请输入行走速度(每走一步的时间,单位毫秒,默认100)", core.values.moveSpeed, function (value) {
|
//浮点运算精度 JS弱类型
|
||||||
value = parseInt(value) || core.values.moveSpeed;
|
var value= parseFloat(Math.sqrt(core.musicStatus.userVolume).toFixed(1));
|
||||||
value = core.clamp(value, 10, 500);
|
core.musicStatus.userVolume = parseFloat(Math.pow(core.clamp(parseFloat(value + delta), 0, 1), 2).toFixed(2));
|
||||||
core.values.moveSpeed = value;
|
//audioContext 音效 不受designVolume 影响
|
||||||
core.setLocalStorage("moveSpeed", value);
|
if(core.musicStatus.gainNode != null) core.musicStatus.gainNode.gain.value = core.musicStatus.userVolume;
|
||||||
core.ui.drawSwitchs();
|
if (core.musicStatus.playingBgm) core.material.bgms[core.musicStatus.playingBgm].volume = core.musicStatus.userVolume * core.musicStatus.designVolume;
|
||||||
});
|
core.setLocalStorage('userVolume', core.musicStatus.userVolume);
|
||||||
|
core.ui.drawSwitchs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actions.prototype._clickSwitchs_moveSpeed = function (delta) {
|
||||||
|
var value = core.clamp(parseInt(core.values.moveSpeed + delta), 50, 200);
|
||||||
|
core.values.moveSpeed = parseInt(value);
|
||||||
|
core.setLocalStorage("moveSpeed", core.values.moveSpeed);
|
||||||
|
core.ui.drawSwitchs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
actions.prototype._clickSwitchs_displayEnemyDamage = function () {
|
actions.prototype._clickSwitchs_displayEnemyDamage = function () {
|
||||||
core.flags.displayEnemyDamage = !core.flags.displayEnemyDamage;
|
core.flags.displayEnemyDamage = !core.flags.displayEnemyDamage;
|
||||||
core.updateDamage();
|
core.updateDamage();
|
||||||
|
|||||||
@ -2251,7 +2251,7 @@ control.prototype._playBgm_play = function (bgm, startTime) {
|
|||||||
// 缓存BGM
|
// 缓存BGM
|
||||||
core.loader.loadBgm(bgm);
|
core.loader.loadBgm(bgm);
|
||||||
// 播放当前BGM
|
// 播放当前BGM
|
||||||
core.material.bgms[bgm].volume = core.musicStatus.volume;
|
core.material.bgms[bgm].volume = core.musicStatus.userVolume * core.musicStatus.designVolume;
|
||||||
core.material.bgms[bgm].currentTime = startTime || 0;
|
core.material.bgms[bgm].currentTime = startTime || 0;
|
||||||
core.material.bgms[bgm].play();
|
core.material.bgms[bgm].play();
|
||||||
core.musicStatus.playingBgm = bgm;
|
core.musicStatus.playingBgm = bgm;
|
||||||
@ -2324,7 +2324,7 @@ control.prototype.playSound = function (sound) {
|
|||||||
core.musicStatus.playingSounds[id] = source;
|
core.musicStatus.playingSounds[id] = source;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.material.sounds[sound].volume = core.musicStatus.volume;
|
core.material.sounds[sound].volume = core.musicStatus.userVolume;
|
||||||
core.material.sounds[sound].play();
|
core.material.sounds[sound].play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,8 @@ function core() {
|
|||||||
'lastBgm': null, // 上次播放的bgm
|
'lastBgm': null, // 上次播放的bgm
|
||||||
'gainNode': null,
|
'gainNode': null,
|
||||||
'playingSounds': {}, // 正在播放的SE
|
'playingSounds': {}, // 正在播放的SE
|
||||||
'volume': 1.0, // 音量
|
'userVolume': 1.0, // 用户音量
|
||||||
|
'designVolume': 1.0, //设计音量
|
||||||
'cachedBgms': [], // 缓存BGM内容
|
'cachedBgms': [], // 缓存BGM内容
|
||||||
'cachedBgmCount': 4, // 缓存的bgm数量
|
'cachedBgmCount': 4, // 缓存的bgm数量
|
||||||
}
|
}
|
||||||
@ -302,6 +303,8 @@ core.prototype._init_platform = function () {
|
|||||||
}
|
}
|
||||||
core.musicStatus.bgmStatus = core.getLocalStorage('bgmStatus', true);
|
core.musicStatus.bgmStatus = core.getLocalStorage('bgmStatus', true);
|
||||||
core.musicStatus.soundStatus = core.getLocalStorage('soundStatus', true);
|
core.musicStatus.soundStatus = core.getLocalStorage('soundStatus', true);
|
||||||
|
//新增 userVolume 默认值1.0
|
||||||
|
core.musicStatus.userVolume = core.getLocalStorage('userVolume', 1.0);
|
||||||
["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"].forEach(function (t) {
|
["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"].forEach(function (t) {
|
||||||
if (navigator.userAgent.indexOf(t) >= 0) {
|
if (navigator.userAgent.indexOf(t) >= 0) {
|
||||||
if (t == 'iPhone' || t == 'iPad' || t == 'iPod') core.platform.isIOS = true;
|
if (t == 'iPhone' || t == 'iPad' || t == 'iPod') core.platform.isIOS = true;
|
||||||
|
|||||||
@ -2540,16 +2540,16 @@ events.prototype.showGif = function (name, x, y) {
|
|||||||
////// 淡入淡出音乐 //////
|
////// 淡入淡出音乐 //////
|
||||||
events.prototype.setVolume = function (value, time, callback) {
|
events.prototype.setVolume = function (value, time, callback) {
|
||||||
var set = function (value) {
|
var set = function (value) {
|
||||||
core.musicStatus.volume = value;
|
core.musicStatus.designVolume = value;
|
||||||
if (core.musicStatus.playingBgm)
|
if (core.musicStatus.playingBgm)
|
||||||
core.material.bgms[core.musicStatus.playingBgm].volume = value;
|
core.material.bgms[core.musicStatus.playingBgm].volume = core.musicStatus.userVolume * core.musicStatus.designVolume;
|
||||||
}
|
}
|
||||||
if (!time || time < 100) {
|
if (!time || time < 100) {
|
||||||
set(value);
|
set(value);
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var currVolume = core.musicStatus.volume;
|
var currVolume = core.musicStatus.designVolume;
|
||||||
time /= Math.max(core.status.replay.speed, 1);
|
time /= Math.max(core.status.replay.speed, 1);
|
||||||
var per_time = 10, step = 0, steps = parseInt(time / per_time);
|
var per_time = 10, step = 0, steps = parseInt(time / per_time);
|
||||||
if (steps <= 0) steps = 1;
|
if (steps <= 0) steps = 1;
|
||||||
|
|||||||
@ -1496,7 +1496,10 @@ ui.prototype.drawSwitchs = function() {
|
|||||||
var choices = [
|
var choices = [
|
||||||
"背景音乐: "+(core.musicStatus.bgmStatus ? "[ON]" : "[OFF]"),
|
"背景音乐: "+(core.musicStatus.bgmStatus ? "[ON]" : "[OFF]"),
|
||||||
"背景音效: "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"),
|
"背景音效: "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"),
|
||||||
"行走速度: "+parseInt(core.values.moveSpeed),
|
//显示为 0~10 十挡
|
||||||
|
" < "+"音量:"+parseInt(parseFloat(Math.sqrt(core.musicStatus.userVolume).toFixed(1)) * 10)+" > ",
|
||||||
|
//数值越大耗时越长
|
||||||
|
" < "+"步时:" + parseInt(core.values.moveSpeed) +" > ",
|
||||||
"怪物显伤: "+(core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"),
|
"怪物显伤: "+(core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"),
|
||||||
"临界显伤: "+(core.flags.displayCritical ? "[ON]" : "[OFF]"),
|
"临界显伤: "+(core.flags.displayCritical ? "[ON]" : "[OFF]"),
|
||||||
"领域显伤: "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"),
|
"领域显伤: "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user