fromFile static method

Future<RenderableTiledMap> fromFile(
  1. String fileName,
  2. Vector2 destTileSize, {
  3. double? atlasMaxX,
  4. double? atlasMaxY,
  5. String prefix = 'assets/tiles/',
  6. CameraComponent? camera,
  7. bool? ignoreFlip,
  8. Images? images,
  9. AssetBundle? bundle,
  10. bool tsxPackingFilter(
    1. Tileset
    )?,
  11. bool useAtlas = true,
  12. Paint layerPaintFactory(
    1. double opacity
    )?,
  13. double atlasPackingSpacingX = 0,
  14. double atlasPackingSpacingY = 0,
})

Parses a file returning a RenderableTiledMap.

This method looks for files under the path "assets/tiles/" by default. This can be changed by providing a different path to prefix.

By default, FlameTileLayer renders flipped tiles if they exist. You can disable this by setting ignoreFlip to true.

Implementation

static Future<RenderableTiledMap> fromFile(
  String fileName,
  Vector2 destTileSize, {
  double? atlasMaxX,
  double? atlasMaxY,
  String prefix = 'assets/tiles/',
  CameraComponent? camera,
  bool? ignoreFlip,
  Images? images,
  AssetBundle? bundle,
  bool Function(Tileset)? tsxPackingFilter,
  bool useAtlas = true,
  Paint Function(double opacity)? layerPaintFactory,
  double atlasPackingSpacingX = 0,
  double atlasPackingSpacingY = 0,
}) async {
  final contents =
      await (bundle ?? Flame.bundle).loadString('$prefix$fileName');
  return fromString(
    contents,
    destTileSize,
    atlasMaxX: atlasMaxX,
    atlasMaxY: atlasMaxY,
    prefix: prefix,
    camera: camera,
    ignoreFlip: ignoreFlip,
    images: images,
    bundle: bundle,
    tsxPackingFilter: tsxPackingFilter,
    useAtlas: useAtlas,
    layerPaintFactory: layerPaintFactory ?? _defaultLayerPaintFactory,
    atlasPackingSpacingX: atlasPackingSpacingX,
    atlasPackingSpacingY: atlasPackingSpacingY,
  );
}