TileMap

Node for 2D tile-based maps.

Tilemaps use a TileSet which contain a list of tiles (textures plus optional collision, navigation, and/or occluder shapes) which are used to create grid-based maps.

@GodotBaseClass
struct TileMap {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

Constants
enum Constants
HalfOffset
enum HalfOffset
Mode
enum Mode
TileOrigin
enum TileOrigin

Functions

_clearQuadrants
void _clearQuadrants()
_getOldCellSize
long _getOldCellSize()
_getTileData
PoolIntArray _getTileData()
_recreateQuadrants
void _recreateQuadrants()
_setCelld
void _setCelld(Vector2 position, Dictionary data)
_setOldCellSize
void _setOldCellSize(long size)
_setTileData
void _setTileData(PoolIntArray arg0)
clear
void clear()

Clears all cells.

fixInvalidTiles
void fixInvalidTiles()

Clears cells that do not exist in the tileset.

getCell
long getCell(long x, long y)

Returns the tile index of the given cell.

getCellSize
Vector2 getCellSize()
getCellv
long getCellv(Vector2 position)

Returns the tile index of the cell given by a Vector2.

getClipUv
bool getClipUv()
getCollisionBounce
double getCollisionBounce()
getCollisionFriction
double getCollisionFriction()
getCollisionLayer
long getCollisionLayer()
getCollisionLayerBit
bool getCollisionLayerBit(long bit)

Returns true if the given collision layer bit is set.

getCollisionMask
long getCollisionMask()
getCollisionMaskBit
bool getCollisionMaskBit(long bit)

Returns true if the given collision mask bit is set.

getCollisionUseKinematic
bool getCollisionUseKinematic()
getCustomTransform
Transform2D getCustomTransform()
getHalfOffset
TileMap.HalfOffset getHalfOffset()
getMode
TileMap.Mode getMode()
getOccluderLightMask
long getOccluderLightMask()
getQuadrantSize
long getQuadrantSize()
getTileOrigin
TileMap.TileOrigin getTileOrigin()
getTileset
Ref!TileSet getTileset()
getUsedCells
Array getUsedCells()

Returns a Vector2 array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from -1).

getUsedCellsById
Array getUsedCellsById(long id)

Returns an array of all cells with the given tile id.

getUsedRect
Rect2 getUsedRect()

Returns a rectangle enclosing the used (non-empty) tiles of the map.

isCellTransposed
bool isCellTransposed(long x, long y)

Returns true if the given cell is transposed, i.e. the x and y axes are swapped.

isCellXFlipped
bool isCellXFlipped(long x, long y)

Returns true if the given cell is flipped in the x axis.

isCellYFlipped
bool isCellYFlipped(long x, long y)

Returns true if the given cell is flipped in the y axis.

isYSortModeEnabled
bool isYSortModeEnabled()
mapToWorld
Vector2 mapToWorld(Vector2 map_position, bool ignore_half_ofs)

Returns the global position corresponding to the given tilemap (grid-based) coordinates. Optionally, the tilemap's half offset can be ignored.

opAssign
TileMap opAssign(T n)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(TileMap other)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(typeof(null) n)
Undocumented in source. Be warned that the author may not have intended to support it.
setCell
void setCell(long x, long y, long tile, bool flip_x, bool flip_y, bool transpose, Vector2 autotile_coord)

Sets the tile index for the cell given by a Vector2. An index of -1 clears the cell. Optionally, the tile can also be flipped, transposed, or given autotile coordinates. Note that data such as navigation polygons and collision shapes are not immediately updated for performance reasons. If you need these to be immediately updated, you can call updateDirtyQuadrants.

setCellSize
void setCellSize(Vector2 size)
setCellv
void setCellv(Vector2 position, long tile, bool flip_x, bool flip_y, bool transpose)

Sets the tile index for the given cell. An index of -1 clears the cell. Optionally, the tile can also be flipped or transposed. Note that data such as navigation polygons and collision shapes are not immediately updated for performance reasons. If you need these to be immediately updated, you can call updateDirtyQuadrants.

setClipUv
void setClipUv(bool enable)
setCollisionBounce
void setCollisionBounce(double value)
setCollisionFriction
void setCollisionFriction(double value)
setCollisionLayer
void setCollisionLayer(long layer)
setCollisionLayerBit
void setCollisionLayerBit(long bit, bool value)

Sets the given collision layer bit.

setCollisionMask
void setCollisionMask(long mask)
setCollisionMaskBit
void setCollisionMaskBit(long bit, bool value)

Sets the given collision mask bit.

setCollisionUseKinematic
void setCollisionUseKinematic(bool use_kinematic)
setCustomTransform
void setCustomTransform(Transform2D custom_transform)
setHalfOffset
void setHalfOffset(long half_offset)
setMode
void setMode(long mode)
setOccluderLightMask
void setOccluderLightMask(long mask)
setQuadrantSize
void setQuadrantSize(long size)
setTileOrigin
void setTileOrigin(long origin)
setTileset
void setTileset(TileSet tileset)
setYSortMode
void setYSortMode(bool enable)
updateBitmaskArea
void updateBitmaskArea(Vector2 position)

Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based x and y coordinates.

updateBitmaskRegion
void updateBitmaskRegion(Vector2 start, Vector2 end)

Applies autotiling rules to the cells in the given region (specified by grid-based x and y coordinates). Calling with invalid (or missing) parameters applies autotiling rules for the entire tilemap.

updateDirtyQuadrants
void updateDirtyQuadrants()

Updates the tile map's quadrants, allowing things such as navigation and collision shapes to be immediately used if modified.

worldToMap
Vector2 worldToMap(Vector2 world_position)

Returns the tilemap (grid-based) coordinatescorresponding to the given global position.

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

cellClipUv
bool cellClipUv [@property getter]
bool cellClipUv [@property setter]
cellCustomTransform
Transform2D cellCustomTransform [@property getter]
Transform2D cellCustomTransform [@property setter]

The custom Transform2D to be applied to the TileMap's cells.

cellHalfOffset
TileMap.HalfOffset cellHalfOffset [@property getter]
long cellHalfOffset [@property setter]

Amount to offset alternating tiles. Uses HALF_OFFSET_* constants. Default value: HALF_OFFSET_DISABLED.

cellQuadrantSize
long cellQuadrantSize [@property getter]
long cellQuadrantSize [@property setter]

The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size. Default value: 16.

cellSize
Vector2 cellSize [@property getter]
Vector2 cellSize [@property setter]

The TileMap's cell size.

cellTileOrigin
TileMap.TileOrigin cellTileOrigin [@property getter]
long cellTileOrigin [@property setter]

Position for tile origin. Uses TILE_ORIGIN_* constants. Default value: TILE_ORIGIN_TOP_LEFT.

cellYSort
bool cellYSort [@property getter]
bool cellYSort [@property setter]

If true the TileMap's children will be drawn in order of their Y coordinate. Default value: false.

collisionBounce
double collisionBounce [@property getter]
double collisionBounce [@property setter]

Bounce value for static body collisions (see collision_use_kinematic). Default value: 0.

collisionFriction
double collisionFriction [@property getter]
double collisionFriction [@property setter]

Friction value for static body collisions (see collision_use_kinematic). Default value: 1.

collisionLayer
long collisionLayer [@property getter]
long collisionLayer [@property setter]

The collision layer(s) for all colliders in the TileMap.

collisionMask
long collisionMask [@property getter]
long collisionMask [@property setter]

The collision mask(s) for all colliders in the TileMap.

collisionUseKinematic
bool collisionUseKinematic [@property getter]
bool collisionUseKinematic [@property setter]

If true TileMap collisions will be handled as a kinematic body. If false collisions will be handled as static body. Default value: false.

mode
TileMap.Mode mode [@property getter]
long mode [@property setter]

The TileMap orientation mode. Uses MODE_* constants. Default value: MODE_SQUARE.

occluderLightMask
long occluderLightMask [@property getter]
long occluderLightMask [@property setter]

The light mask assigned to all light occluders in the TileMap. The TileSet's light occluders will cast shadows only from Light2D(s) that have the same light mask(s).

tileSet
TileSet tileSet [@property getter]
TileSet tileSet [@property setter]

The assigned TileSet.

Static functions

_new
TileMap _new()
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

_classBinding
struct _classBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
ToRef as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta