The documentation at https://www.monogameextended.net/docs/features/2d-animations/animatedsprite/ states that event handlers must be unsubscribed to prevent them from accumulating and being executed multiple times.
However, the actual implementation creates a new AnimationController each time AnimatedSprite.SetAnimation() is called. This effectively discards all previously registered handlers, making manual unsubscription unnecessary.
It’s also unclear whether the “Persistent Event Handler Pattern” described on that page is applicable. Since SetAnimation() replaces the existing AnimationController, any previously attached handlers would no longer be invoked. (I haven’t verified this in practice, as the sample code provided on that page does not compile.)
The documentation at https://www.monogameextended.net/docs/features/2d-animations/animatedsprite/ states that event handlers must be unsubscribed to prevent them from accumulating and being executed multiple times.
However, the actual implementation creates a new
AnimationControllereach timeAnimatedSprite.SetAnimation()is called. This effectively discards all previously registered handlers, making manual unsubscription unnecessary.It’s also unclear whether the “Persistent Event Handler Pattern” described on that page is applicable. Since
SetAnimation()replaces the existingAnimationController, any previously attached handlers would no longer be invoked. (I haven’t verified this in practice, as the sample code provided on that page does not compile.)