load static method

Future<Sprite> load(
  1. String src, {
  2. Vector2? srcPosition,
  3. Vector2? srcSize,
  4. Images? images,
})

Takes a path of an image, a srcPosition and srcSize and loads the sprite animation. When the images is omitted, the global Flame.images is used.

Implementation

static Future<Sprite> load(
  String src, {
  Vector2? srcPosition,
  Vector2? srcSize,
  Images? images,
}) async {
  final imagesCache = images ?? Flame.images;
  final image = await imagesCache.load(src);
  return Sprite(image, srcPosition: srcPosition, srcSize: srcSize);
}