@@ -16,7 +16,8 @@ public class SpriteAnimationGroup : GenericDataHolder {
1616 /// </summary>
1717 public SpriteAnimation CurrentAnimation {
1818 get {
19- this . SortAnimationsIfDirty ( true ) ;
19+ if ( this . SortAnimationsIfDirty ( ) || this . currentAnimation == null )
20+ this . FindAnimationToPlay ( ) ;
2021 return this . currentAnimation ? . Animation ;
2122 }
2223 }
@@ -99,7 +100,7 @@ public SpriteAnimation ByName(string name) {
99100 }
100101
101102 private void FindAnimationToPlay ( ) {
102- this . SortAnimationsIfDirty ( false ) ;
103+ this . SortAnimationsIfDirty ( ) ;
103104
104105 ConditionedAnimation animToPlay = null ;
105106 if ( this . currentAnimation != null && this . currentAnimation . ShouldPlay ( ) )
@@ -122,13 +123,12 @@ private void FindAnimationToPlay() {
122123 }
123124 }
124125
125- private void SortAnimationsIfDirty ( bool findAnimationToPlay ) {
126- if ( this . animationsDirty ) {
127- this . animationsDirty = false ;
128- this . animations . Sort ( ( a1 , a2 ) => a2 . Priority . CompareTo ( a1 . Priority ) ) ;
129- if ( findAnimationToPlay )
130- this . FindAnimationToPlay ( ) ;
131- }
126+ private bool SortAnimationsIfDirty ( ) {
127+ if ( ! this . animationsDirty )
128+ return false ;
129+ this . animationsDirty = false ;
130+ this . animations . Sort ( ( a1 , a2 ) => a2 . Priority . CompareTo ( a1 . Priority ) ) ;
131+ return true ;
132132 }
133133
134134 /// <summary>
0 commit comments