AnimatedSprite.fromJson constructor

AnimatedSprite.fromJson(
  1. Map<String, dynamic> json
)

parse animation json

Implementation

factory AnimatedSprite.fromJson(Map<String, dynamic> json) {
  final index = json['index'];
  final time = json['time'];
  return AnimatedSprite(
    imagePath: json['imagePath'],
    transform: Transform2D.fromJson(json['transform']),
    frames: json['frames']
        .map<Frame>(
            (frame) => Frame.fromJson(frame, imagePath: json['imagePath']))
        .toList(),
    index: index == null ? 0 : index as int,
    time: time == null ? 0.0 : (time as num).toDouble(),
  );
}