MonoGame.Samples
MonoGame.Samples copied to clipboard
Minor fixes for the AudioController.Update() at 2D Tutorial
Fix for the https://github.com/MonoGame/MonoGame/discussions/8851
This code fixed two things in AudiroController.Update() at 2D game tutorial.
- move "_activeSoundEffectInstances.RemoveAt(index)" into if block.
- add index++ at the end of while statement.
public void Update()
{
int index = 0;
while (index < _activeSoundEffectInstances.Count)
{
SoundEffectInstance instance = _activeSoundEffectInstances[index];
if (instance.State == SoundState.Stopped && !instance.IsDisposed)
{
instance.Dispose();
_activeSoundEffectInstances.RemoveAt(index);
}
index++;
}
}
I think it's still a bit broken, see https://github.com/MonoGame/docs.monogame.github.io/pull/148#issuecomment-2990138927
Can you review again @nahaharo / @AristurtleDev to ensure the update is the latest?
I think its okay
Sorry for the dealy on checking the changes.
@SimonDarksideJ The code looks good, it implements the reverse loop in each of the chapter sources.
Thanks for the contribution @nahaharo