Skip to content

Commit

Permalink
fix: Clarify SpriteGroupComponent.updateSprite assertion (#3317)
Browse files Browse the repository at this point in the history
Now the assertion is slightly clearer for what the user has done wrong
when calling the `SpriteGroupComponent.updateSprite` in an instance
without an initialized `sprites` map.
  • Loading branch information
spydon authored Sep 22, 2024
1 parent 714d9c7 commit d976ee8
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ class SpriteGroupComponent<T> extends PositionComponent

/// Updates the sprite for the given key.
void updateSprite(T key, Sprite sprite) {
assert(_sprites != null, 'Sprites map is not yet initialized');
assert(
_sprites != null,
'This call can only be made after the sprites map has been initialized, '
'which should be done in either the constructor or in onLoad.',
);
_sprites?[key] = sprite;
_resizeToSprite();
}
Expand Down

0 comments on commit d976ee8

Please sign in to comment.