TileSetItem.fromJson constructor

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

Implementation

TileSetItem.fromJson(Map<String, dynamic> json) {
  id = json['id'];
  typeOrClass = json['type'] ?? json['class'];
  image = json['image'];
  imageHeight = double.tryParse(json['imageheight'].toString());
  imageWidth = double.tryParse(json['imagewidth'].toString());
  probability = double.tryParse(json['probability'].toString());
  if (json['terrain'] != null) {
    terrain = <int>[];
    json['terrain'].forEach((v) {
      terrain?.add(v);
    });
  }
  objectGroup = json['objectgroup'] != null
      ? TileSetObjectGroup.fromJson(json['objectgroup'])
      : null;
  if (json['animation'] != null) {
    animation = <FrameAnimation>[];
    json['animation'].forEach((v) {
      animation?.add(FrameAnimation.fromJson(v));
    });
  }
  if (json['properties'] != null) {
    properties = <Property>[];
    json['properties'].forEach((v) {
      properties?.add(Property.fromJson(v));
    });
  }
}