getSprite static method
Implementation
static Sprite getSprite(
String image,
Vector2 position,
Vector2 size,
) {
final pathCache = '$image/${position.x}/${position.y}';
if (spriteCache.containsKey(pathCache)) {
return spriteCache[pathCache]!;
}
final spriteSheetImg = getImageCache(image);
return spriteCache[pathCache] = spriteSheetImg!.getSprite(
position: Vector2(position.x * size.x, position.y * size.y),
size: Vector2(
size.x == 0.0 ? spriteSheetImg.width.toDouble() : size.x,
size.y == 0.0 ? spriteSheetImg.height.toDouble() : size.y,
),
);
}