Class TCastleTiledMap
Unit
CastleTiledMap
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
Fields
Methods
Properties
Description
Nested Types
|
TLayerIndex = 0..30; |
Layer index that can be used with Layers.
|
Fields
Methods
|
constructor Create(AOwner: TComponent); override; |
This item has no description. |
|
destructor Destroy; override; |
This item has no description. |
|
procedure BeforeDestruction; override; |
This item has no description. |
|
procedure PlayAnimations; |
This item has no description. |
|
procedure StopAnimations(const ResetAnimations: Boolean); |
This item has no description. |
|
function HasAnimations: Boolean; |
This item has no description. |
|
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
|
property Data: TCastleTiledMapData read FData; |
Currently loaded map (from Url), if any. Nil if no map is loaded (when Url is empty). Read-only.
|
|
property Map: TCastleTiledMapData read FData; deprecated 'use Data'; |
Warning: this symbol is deprecated: use Data This item has no description. |
|
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.
|
|
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.
|
|
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).
|
|
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.
|
|
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.