RenderableTiledMap class
This is a wrapper over Tiled's TiledMap which can be rendered to a canvas.
Internally each layer is wrapped with a RenderableLayer
which handles
rendering and caching for supported layer types:
- TileLayer is supported with pre-computed SpriteBatches
- ImageLayer is supported with paintImage
This also supports the following properties:
- TiledMap.backgroundColor
- Layer.opacity
- Layer.offsetX
- Layer.offsetY
- Layer.parallaxX (only supported if a
CameraComponent
is supplied) - Layer.parallaxY (only supported if a
CameraComponent
is supplied)
Constructors
Properties
-
animationFrames
→ Map<
Tile, TileFrames> -
final
- camera ↔ CameraComponent?
-
Camera used for determining the current viewport for layer rendering.
Optional, but required for parallax support
getter/setter pair
- destTileSize → Vector2
-
The target size for each tile in the tiled map.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- map → TiledMap
-
TiledMap instance for this map.
final
-
renderableLayers
→ List<
RenderableLayer< Layer> > -
Layers to be rendered, in the same order as TiledMap.layers
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getLayer<
T extends Layer> (String name) → T? -
Returns a layer of type
T
with givenname
from all the layers of this map. If no such layer is found, null is returned. -
getLayerVisibility(
int layerId) → bool - Gets the visibility of the corresponding layer
-
getTileData(
{required int layerId, required int x, required int y}) → Gid? - Gets the Gid of the corresponding layer at the given position
-
handleResize(
Vector2 canvasSize) → void - Handle game resize and propagate it to renderable layers
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
Canvas c) → void - Renders each renderable layer in the same order specified by the Tiled map
-
setLayerVisibility(
int layerId, {required bool visible}) → void - Changes the visibility of the corresponding layer, if different
-
setTileData(
{required int layerId, required int x, required int y, required Gid gid}) → void - Changes the Gid of the corresponding layer at the given position, if different
-
tileStack(
int x, int y, {Set< String> named = const <String>{}, Set<int> ids = const <int>{}, bool all = false}) → TileStack -
Select a group of tiles from the coordinates
x
andy
. -
toString(
) → String -
A string representation of this object.
inherited
-
update(
double dt) → void
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromFile(
String fileName, Vector2 destTileSize, {double? atlasMaxX, double? atlasMaxY, String prefix = 'assets/tiles/', CameraComponent? camera, bool? ignoreFlip, Images? images, AssetBundle? bundle, bool tsxPackingFilter(Tileset)?, bool useAtlas = true, Paint layerPaintFactory(double opacity)?, double atlasPackingSpacingX = 0, double atlasPackingSpacingY = 0}) → Future< RenderableTiledMap> -
Parses a file returning a
RenderableTiledMap
. -
fromString(
String contents, Vector2 destTileSize, {double? atlasMaxX, double? atlasMaxY, String prefix = 'assets/tiles/', CameraComponent? camera, bool? ignoreFlip, Images? images, AssetBundle? bundle, bool tsxPackingFilter(Tileset)?, bool useAtlas = true, Paint layerPaintFactory(double opacity)?, double atlasPackingSpacingX = 0, double atlasPackingSpacingY = 0}) → Future< RenderableTiledMap> -
Parses a string returning a
RenderableTiledMap
. -
fromTiledMap(
TiledMap map, Vector2 destTileSize, {double? atlasMaxX, double? atlasMaxY, CameraComponent? camera, bool? ignoreFlip, Images? images, AssetBundle? bundle, bool tsxPackingFilter(Tileset)?, bool useAtlas = true, Paint layerPaintFactory(double opacity)?, double atlasPackingSpacingX = 0, double atlasPackingSpacingY = 0}) → Future< RenderableTiledMap> -
Parses a TiledMap returning a
RenderableTiledMap
.