getSpriteById method

Sprite getSpriteById(
  1. int spriteId
)

Gets the sprite with id spriteId from the grid.

The ids are defined as starting at 0 on the top left and going sequentially on each row. This is lazily computed and cached for your convenience.

Implementation

Sprite getSpriteById(int spriteId) {
  return _spriteCache[spriteId] ??= _computeSprite(spriteId);
}