stopSound
This commit is contained in:
parent
7586b3fe45
commit
8d7365b683
@ -2667,7 +2667,6 @@ control.prototype.playSound = function (sound) {
|
||||
var source = core.musicStatus.audioContext.createBufferSource();
|
||||
source.buffer = core.material.sounds[sound];
|
||||
source.connect(core.musicStatus.gainNode);
|
||||
source.loop = true;
|
||||
var id = parseInt(Math.random()*10000000);
|
||||
source.onended = function () {
|
||||
delete core.musicStatus.playingSounds[id];
|
||||
@ -2697,6 +2696,23 @@ control.prototype.playSound = function (sound) {
|
||||
}
|
||||
}
|
||||
|
||||
control.prototype.stopSound = function () {
|
||||
for (var i in core.musicStatus.playingSounds) {
|
||||
var source = core.musicStatus.playingSounds[i];
|
||||
try {
|
||||
source.stop();
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
source.noteOff(0);
|
||||
}
|
||||
catch (e) {
|
||||
main.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
control.prototype.checkBgm = function() {
|
||||
core.playBgm(core.musicStatus.playingBgm || main.startBgm);
|
||||
}
|
||||
|
||||
@ -1502,6 +1502,11 @@ core.prototype.playSound = function (sound) {
|
||||
core.control.playSound(sound);
|
||||
}
|
||||
|
||||
////// 停止所有音效 //////
|
||||
core.prototype.stopSound = function () {
|
||||
core.control.stopSound();
|
||||
}
|
||||
|
||||
////// 动画显示某对象 //////
|
||||
core.prototype.show = function (obj, speed, callback) {
|
||||
core.utils.show(obj, speed, callback);
|
||||
|
||||
@ -960,20 +960,7 @@ events.prototype.doAction = function() {
|
||||
this.doAction();
|
||||
break;
|
||||
case "stopSound":
|
||||
for (var i in core.musicStatus.playingSounds) {
|
||||
var source = core.musicStatus.playingSounds[i];
|
||||
try {
|
||||
source.stop();
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
source.noteOff(0);
|
||||
}
|
||||
catch (e) {
|
||||
main.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
core.stopSound();
|
||||
break;
|
||||
case "setVolume":
|
||||
data.value = core.clamp(parseInt(data.value)/100, 0, 1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user