load static method
Future<TiledComponent<FlameGame<World> > >
load(
- String fileName,
- Vector2 destTileSize, {
- double? atlasMaxX,
- double? atlasMaxY,
- String prefix = 'assets/tiles/',
- int? priority,
- bool? ignoreFlip,
- AssetBundle? bundle,
- Images? images,
- bool tsxPackingFilter()?,
- bool useAtlas = true,
- Paint layerPaintFactory(
- double opacity
- double atlasPackingSpacingX = 0,
- double atlasPackingSpacingY = 0,
- ComponentKey? key,
- String? package,
Loads a TiledComponent from a file.
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, RenderableTiledMap renders flipped tiles if they exist.
You can disable it by passing ignoreFlip as true.
A custom atlasMaxX and atlasMaxY can be provided in case you want to
change the max size of TiledAtlas that TiledComponent creates
internally.
TiledComponent uses Flame's SpriteBatch to render the map. Which under
the hood uses Canvas.drawAtlas calls to render the tiles. This behavior
can be changed by setting useAtlas to false. This will make the map
be rendered with Canvas.drawImageRect calls instead.
Implementation
static Future<TiledComponent> load(
String fileName,
Vector2 destTileSize, {
double? atlasMaxX,
double? atlasMaxY,
String prefix = 'assets/tiles/',
int? priority,
bool? ignoreFlip,
AssetBundle? bundle,
Images? images,
bool Function(Tileset)? tsxPackingFilter,
bool useAtlas = true,
Paint Function(double opacity)? layerPaintFactory,
double atlasPackingSpacingX = 0,
double atlasPackingSpacingY = 0,
ComponentKey? key,
String? package,
}) async {
return TiledComponent(
await RenderableTiledMap.fromFile(
fileName,
destTileSize,
atlasMaxX: atlasMaxX,
atlasMaxY: atlasMaxY,
ignoreFlip: ignoreFlip,
prefix: prefix,
bundle: bundle,
images: images,
tsxPackingFilter: tsxPackingFilter,
useAtlas: useAtlas,
layerPaintFactory: layerPaintFactory,
atlasPackingSpacingX: atlasPackingSpacingX,
atlasPackingSpacingY: atlasPackingSpacingY,
package: package,
),
priority: priority,
key: key,
);
}