load static method

Future<TypledSpriteAtlas> load(
  1. String path, {
  2. AssetsCache? cache,
  3. bool disablePadding = false,
})

Loads a TypledSpriteAtlas from the given asset path.

When disablePadding is true, the original image is used as-is without edge-repeated padding.

Implementation

static Future<TypledSpriteAtlas> load(
  String path, {
  AssetsCache? cache,
  bool disablePadding = false,
}) async {
  final atlas = await _loadAtlas(path, cache: cache);
  final originalImage = await Flame.images.load(atlas.imagePath);
  const padding = 2;
  final image = disablePadding
      ? originalImage
      : await _createPaddedAtlas(originalImage, atlas.tileSize, padding);
  return TypledSpriteAtlas(
    atlas: atlas,
    tileSize: atlas.tileSize.toDouble(),
    image: image,
    padding: disablePadding ? 0 : padding,
  );
}