getFutureSprite static method
Implementation
static Future<Sprite> getFutureSprite(
String image, {
Vector2? position,
Vector2? size,
}) async {
String pathCache = '$image/${position?.x ?? 0}/${position?.y ?? 0}';
if (spriteCache.containsKey(pathCache)) {
return Future.value(spriteCache[pathCache]);
}
Image spriteSheetImg = await loadImage(
image,
);
return spriteCache[pathCache] = spriteSheetImg.getSprite(
position: Vector2(
((position?.x ?? 0.0) * (size?.x ?? 0.0)),
((position?.y ?? 0.0) * (size?.y ?? 0.0)),
),
size: Vector2(
(size?.x ?? 0.0) == 0.0 ? spriteSheetImg.width.toDouble() : size!.x,
(size?.y ?? 0.0) == 0.0 ? spriteSheetImg.height.toDouble() : size!.y,
),
);
}