SpriteAnimation.fromFrameData constructor

SpriteAnimation.fromFrameData(
  1. Image image,
  2. SpriteAnimationData data
)

Create animation from a single image that contains all frames.

The data argument provides the description of where the individual sprites are located within the main image.

Implementation

factory SpriteAnimation.fromFrameData(
  Image image,
  SpriteAnimationData data,
) {
  return SpriteAnimation(
    [
      for (final frameData in data.frames)
        SpriteAnimationFrame(
          Sprite(
            image,
            srcSize: frameData.srcSize,
            srcPosition: frameData.srcPosition,
          ),
          frameData.stepTime,
        ),
    ],
    loop: data.loop,
  );
}