Class TCastleTiledMapControl
Unit
Declaration
type TCastleTiledMapControl = class(TCastleUserInterface)
Description
Display a map created in Tiled (https://www.mapeditor.org/).
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleUserInterface
- TCastleTiledMapControl
Overview
Methods
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Render; override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
procedure LoadFromFile(const AURL: string); deprecated 'set URL instead of calling LoadFromFile'; |
|
function PositionToTile(const Position: TVector2; const ContainerCoordinates: Boolean; out TilePosition: TVector2Integer): Boolean; |
|
function TileRectangle(const TilePosition: TVector2Integer; const ContainerCoordinates: Boolean): TFloatRectangle; overload; |
|
function TileRectangle(const TilePosition: TVector2Integer; const ContainerCoordinates: Boolean; const ForceTileWidth, ForceTileHeight: Single): TFloatRectangle; overload; |
Properties
property Origin: TVector2 read FOrigin write SetOrigin; |
|
property Map: TTiledMap read FMap; |
|
property ClipChildren default true; |
|
property URL: String read FURL write SetURL; |
|
property Scale: Single read FScale write SetScale default 1; |
|
property ObjectsVisible: Boolean read FObjectsVisible write FObjectsVisible default true; |
|
property SmoothScaling: Boolean read FSmoothScaling write SetSmoothScaling
default false; |
|
property SmoothScalingSafeBorder: Boolean read FSmoothScalingSafeBorder write SetSmoothScalingSafeBorder
default false; |
|
property OriginPersistent: TCastleVector2Persistent read FOriginPersistent ; |
Description
Methods
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Render; override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
function PositionToTile(const Position: TVector2; const ContainerCoordinates: Boolean; out TilePosition: TVector2Integer): Boolean; |
|
Detect tile under given position. The interpretation of Position depends on ContainerCoordinates, and is similar to e.g. TCastleViewport.PositionToCameraPlane:
Note that you can query the positions that are outside of this UI control, or even outside of the container. They will return correct map tiles, as if the map was rendered there. If you want to avoid this, you can e.g. check whether Position is inside the RenderRect (if it's a position in container coordinates, with ContainerCoordinates = This method returns |
function TileRectangle(const TilePosition: TVector2Integer; const ContainerCoordinates: Boolean): TFloatRectangle; overload; |
|
Rectangle where the given map tile is rendered. Useful to render something over a TCastleTiledMapControl, e.g. a pawn in a game. In some way, this method is an inverse of the PositionToTile method. It converts map (tile) coordinates back into coordinates useful to display something. The ContainerCoordinates value determines the coordinate system of the resulting rectangle. It's meaning is similar to the ContainerCoordinates parameter of the PositionToTile method.
This method works for any TilePosition, even outside of valid map positions. Returns TFloatRectangle.Empty is Map not loaded (URL not set). Some maps may use tilesets in which image size is different than map tile size. That is, TTiledMap.TTileset.TileWidth may be different than TTiledMap.TileWidth for some tilesets. The simpler version of this method, without ForceTileWidth/Height, just returns the size of the map tile looking at (TTiledMap.TileWidth, TTiledMap.TileHeight), since it doesn't know the tileset you use. You can pass ForceTileWidth and ForceTileHeight to set particular size. |
function TileRectangle(const TilePosition: TVector2Integer; const ContainerCoordinates: Boolean; const ForceTileWidth, ForceTileHeight: Single): TFloatRectangle; overload; |
|
Properties
property Origin: TVector2 read FOrigin write SetOrigin; |
|
|
property Map: TTiledMap read FMap; |
|
Currently loaded |
property ClipChildren default true; |
|
property URL: String read FURL write SetURL; |
|
|
property Scale: Single read FScale write SetScale default 1; |
|
property ObjectsVisible: Boolean read FObjectsVisible write FObjectsVisible default true; |
|
Show objects like polylines and points on the map. |
property SmoothScaling: Boolean read FSmoothScaling write SetSmoothScaling
default false; |
|
How are images scaled (because of UI scaling, because of Scale). Beware that using |
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 color 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. |
property OriginPersistent: TCastleVector2Persistent read FOriginPersistent ; |
|
Origin that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Origin directly. See also |
Generated by PasDoc 0.16.0.