Simplified logic for removal of destroyed sounds

This commit is contained in:
Pavle Goloskokovic 2018-01-05 20:14:34 +01:00
parent efbf276dc9
commit 7c2bd98e44

View file

@ -198,13 +198,9 @@ var BaseSoundManager = new Class({
* @param {number} delta - The delta time elapsed since the last frame. * @param {number} delta - The delta time elapsed since the last frame.
*/ */
update: function (time, delta) { update: function (time, delta) {
this.sounds.sort(function (s1, s2) { for (var i = this.sounds.length - 1; i >= 0; i--) {
return (s1.pendingRemove === s2.pendingRemove) ? 0 : s1 ? 1 : -1;
});
for (var i = 0; i < this.sounds.length; i++) {
if (this.sounds[i].pendingRemove) { if (this.sounds[i].pendingRemove) {
this.sounds.length = i; this.sounds.splice(i, 1);
break;
} }
} }
this.sounds.forEach(function (sound) { this.sounds.forEach(function (sound) {