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