fromJSONAtlasAsMap method

Future<Map<String, Sprite>> fromJSONAtlasAsMap(
  1. String imagePath,
  2. String dataPath
)

Implementation

Future<Map<String, Sprite>> fromJSONAtlasAsMap(
    String imagePath, String dataPath) async {
  final jsonFrames = await _loadJsonFrames(dataPath);
  final image = await Flame.images.load(imagePath);
  final Map<String, Sprite> map = {};

  jsonFrames.forEach((filename, value) {
    final id = _filenameWithoutExtension(filename);
    map[id] = _createSprite(value, image);
  });

  return map;
}