Class TCastleTiledMap

Unit

Declaration

type TCastleTiledMap = class(TCastleTransform)

Description

Display a map created in Tiled in a viewport. See https://castle-engine.io/tiled_maps for a documentation.

Hierarchy

Overview

Nested Types

Public TLayerIndex = 0..30;
Public TLayers = set of TLayerIndex;

Fields

Public nested const AllLayers = [Low(TLayerIndex)..High(TLayerIndex)];

Methods

Protected function InternalBuildNodeInside: TObject; override;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure BeforeDestruction; override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;
Public procedure PlayAnimations;
Public procedure StopAnimations(const ResetAnimations: Boolean);
Public function HasAnimations: Boolean;
Public function TileRectangle(const TilePosition: TVector2Integer; const TilesetIndex: Cardinal = 0): TFloatRectangle;

Properties

Public property Data: TCastleTiledMapData read FData;
Public property Map: TCastleTiledMapData read FData; deprecated 'use Data';
Published property Url: String read FUrl write SetUrl;
Published property SmoothScaling: Boolean read FSmoothScaling write SetSmoothScaling default false;
Published property SmoothScalingSafeBorder: Boolean read FSmoothScalingSafeBorder write SetSmoothScalingSafeBorder default false;
Published property ForceTilesetSpacing: Boolean read FForceTilesetSpacing write SetForceTilesetSpacing default false;
Published property Layers: TLayers read FLayers write SetLayers default AllLayers;

Description

Nested Types

Public TLayerIndex = 0..30;

Layer index that can be used with Layers.

Public TLayers = set of TLayerIndex;

Type for Layers, set of visible layers.

Fields

Public nested const AllLayers = [Low(TLayerIndex)..High(TLayerIndex)];

Indicates that all Layers should be visible.

Methods

Protected function InternalBuildNodeInside: TObject; override;

This item has no description. Showing description inherited from TCastleTransform.InternalBuildNodeInside.

Helper for InternalBuildNode. Result must be TAbstractChildNode or Nil.

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public procedure BeforeDestruction; override;

This item has no description.

Public function PropertySections(const PropertyName: String): TPropertySections; override;

This item has no description. Showing description inherited from TCastleComponent.PropertySections.

Section where to show property in the editor.

Public procedure PlayAnimations;

This item has no description.

Public procedure StopAnimations(const ResetAnimations: Boolean);

This item has no description.

Public function HasAnimations: Boolean;

This item has no description.

Public function TileRectangle(const TilePosition: TVector2Integer; const TilesetIndex: Cardinal = 0): TFloatRectangle;

Rectangle coordinates where a tile at given TilePosition would be rendered on the map. This doesn't check whether TilePosition is within map range – any coordinates (negative, or larger than map size) are allowed.

Properties

Public property Data: TCastleTiledMapData read FData;

Currently loaded map (from Url), if any. Nil if no map is loaded (when Url is empty). Read-only.

Public property Map: TCastleTiledMapData read FData; deprecated 'use Data';

Warning: this symbol is deprecated: use Data

This item has no description.

Published property Url: String read FUrl write SetUrl;

URL (or just filename) of the Tiled map file (TMX).

Note that loading new map from new URL automatically starts animations. You can stop them with StopAnimations.

Published property SmoothScaling: Boolean read FSmoothScaling write SetSmoothScaling default false;

How are images scaled. True means we use nice "bilinear" filter. False means we use pixelated "nearest" filter.

Beware that using True, and scaling the map, requires preparing the tileset (atlas of tile images) in a proper way. The space around each tile must have at least 1-pixel margin filled with the same color and alpha, otherwise bad colors will creep in because of bilinear filtering. See alpha bleeding. Alternatively, you can use SmoothScalingSafeBorder.

Published property SmoothScalingSafeBorder: Boolean read FSmoothScalingSafeBorder write SetSmoothScalingSafeBorder default false;

In case of SmoothScaling, prevent the color outside of rendered frame from creeping in, by stretching the rendered frame a bit. See TSprite.SmoothScalingSafeBorder.

It is better to prepare the sprite (tileset) images with some spacing between tiles, and alpha bleeding instead of using this property. This property workarounds the fact that some sprite (tileset) images lack proper spacing and color bleeding, but it distorts the image a bit, so it's no longer pixel-perfect.

Note that changing this when map is loaded reloads it, and automatically starts animations. You can stop them with StopAnimations.

See also ForceTilesetSpacing that workarounds artifacts with SmoothScaling in a different way, by adding spacing in the tileset texture, which makes this trick (SmoothScalingSafeBorder) not necessary. Do not use both ForceTilesetSpacing and SmoothScalingSafeBorder – these 2 properties are different workarounds for the same problem, it doesn't make sense to use them both.

See also
ForceTilesetSpacing
Use a modified version of the tileset image, with a proper space between each tile in the texture (1-pixel size border around each tile, effectively 2-pixel wide spacing between each tile).
Published property ForceTilesetSpacing: Boolean read FForceTilesetSpacing write SetForceTilesetSpacing default false;

Use a modified version of the tileset image, with a proper space between each tile in the texture (1-pixel size border around each tile, effectively 2-pixel wide spacing between each tile).

Makes sense to be used only with SmoothScaling = True, it is pointless (but harmless) when SmoothScaling = False.

See also SmoothScalingSafeBorder that workarounds artifacts with SmoothScaling in a different way, by changing texture coordinates such that this spacing is not necessary. Do not use both SmoothScalingSafeBorder and ForceTilesetSpacing – these 2 properties are different workarounds for the same problem, it doesn't make sense to use them both.

Note that changing this when map is loaded reloads it, and automatically starts animations. You can stop them with StopAnimations.

See also
SmoothScalingSafeBorder
In case of SmoothScaling, prevent the color outside of rendered frame from creeping in, by stretching the rendered frame a bit.
Published property Layers: TLayers read FLayers write SetLayers default AllLayers;

Layers to include when loading this map.

Note that changing this when map is loaded reloads it, and automatically starts animations. You can stop them with StopAnimations.

TODO: There is an alternative way to hide/show layers: you can read/write MyMap.Data.Layers[<layer-index>].Exists property. However, we do not encourage using the Data property now, and we plan to add a better layer API, see https://castle-engine.io/roadmap#tiled_layers . So eventually, we want to allow just using MyMap.Layers[<layer-index>].Exists to hide/show layers.


Generated by PasDoc 0.16.0-snapshot.