Skip to content

Commit 267cfed

Browse files
Implemented removeByKey method
1 parent 5f56d03 commit 267cfed

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

v3/src/sound/BaseSoundManager.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,16 @@ var BaseSoundManager = new Class({
142142
}
143143
return false;
144144
},
145-
removeByKey: NOOP,
145+
removeByKey: function (key) {
146+
var removed = 0;
147+
for (var i = this.sounds.length - 1; i >= 0; i--) {
148+
if (this.sounds[i].key === key) {
149+
this.sounds.splice(i, 1);
150+
removed++;
151+
}
152+
}
153+
return removed;
154+
},
146155
pauseAll: function () {
147156
this.sounds.forEach(function (sound) {
148157
sound.pause();

0 commit comments

Comments
 (0)