loadAsset static method

Future<FireAtlas> loadAsset(
  1. String fileName, {
  2. AssetsCache? assets,
  3. Images? images,
  4. bool encoded = true,
})

Loads the FireAtlas from an asset.

Use encoded = false to load the asset from a json file.

Implementation

static Future<FireAtlas> loadAsset(
  String fileName, {
  AssetsCache? assets,
  Images? images,
  bool encoded = true,
}) async {
  final assetsCache = assets ?? Flame.assets;
  final FireAtlas atlas;
  if (encoded) {
    final bytes = await assetsCache.readBinaryFile(fileName);
    atlas = FireAtlas.deserializeBytes(bytes);
  } else {
    final json = await assetsCache.readJson(fileName);
    atlas = FireAtlas.deserializeJson(json);
  }
  await atlas.loadImage(images: images);
  return atlas;
}