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.
*/
update: function (time, delta) {
this.sounds.sort(function (s1, s2) {
return (s1.pendingRemove === s2.pendingRemove) ? 0 : s1 ? 1 : -1;
});
for (var i = 0; i < this.sounds.length; i++) {
for (var i = this.sounds.length - 1; i >= 0; i--) {
if (this.sounds[i].pendingRemove) {
this.sounds.length = i;
break;
this.sounds.splice(i, 1);
}
}
this.sounds.forEach(function (sound) {