mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Added logic for removing destroyed sounds from sounds array on BaseSoundManager update call
This commit is contained in:
parent
cf31ed9a4d
commit
b3fad218bc
1 changed files with 9 additions and 1 deletions
|
@ -194,7 +194,15 @@ var BaseSoundManager = new Class({
|
|||
* @param {number} delta - The delta time elapsed since the last frame.
|
||||
*/
|
||||
update: function (time, delta) {
|
||||
// TODO remove pending sounds
|
||||
this.sounds.sort(function (s1, s2) {
|
||||
return (s1.pendingRemove === s2.pendingRemove) ? 0 : s1 ? 1 : -1;
|
||||
});
|
||||
for (var i = this.sounds.length - 1; i >= 0; i--) {
|
||||
if (!this.sounds[i].pendingRemove) {
|
||||
this.sounds.splice(this.sounds.length - 1 - i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.sounds.forEach(function (sound) {
|
||||
sound.update(time, delta);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue