SpriteSheet<T>.single constructor

SpriteSheet<T>.single(
  1. String asset,
  2. Vector2 size, {
  3. required num fps,
  4. T? key,
  5. bool? loop,
})

Cuts an image that holds one animation, under the name key.

For art that ships a file per animation, where the row is the whole sheet and there is nothing to number.

Implementation

factory SpriteSheet.single(
  String asset,
  Vector2 size, {
  required num fps,
  T? key,
  bool? loop,
}) {
  final sheet = SpriteSheet<T>(
    asset,
    size,
    fps: fps,
    loop: loop,
    rows: [SheetRow<T>(key: key)],
  );

  if (sheet.rows != 1) {
    throw ArgumentError.value(
      size,
      'size',
      'Cuts ${sheet.rows} rows out of this image, not one.',
    );
  }

  return sheet;
}