Enumerationmigueldeicaza.swiftgodot 0.46.0SwiftGodot
VisibilityMode
TileMap.swift:29enum VisibilityMode
Cases
case `default`
Use the debug settings to determine visibility.
case forceHide
Always hide.
case forceShow
Always show.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (57) members.
Type members
Instance members
var changed: SimpleSignal
Emitted when the
TileSet
of this TileMap changes.var collisionAnimatable: Bool
If enabled, the TileMap will see its collisions synced to the physics tick and change its collision type from static to kinematic. This is required to create TileMap-based moving platform.
var collisionVisibilityMode: TileMap.VisibilityMode
Show or hide the TileMap’s collision shapes. If set to .
default
, this depends on the show collision debug settings.var renderingQuadrantSize: Int32
The TileMap’s quadrant size. A quadrant is a group of tiles to be drawn together on a single canvas item, for optimization purposes.
renderingQuadrantSize
defines the length of a square’s side, in the map’s coordinate system, that forms the quadrant. Thus, the default quadrant size groups together16 * 16 = 256
tiles.var tileSet: TileSet?
The
TileSet
used by thisTileMap
. The textures, collisions, and additional behavior of all available tiles are stored here.func addLayer(toPosition: Int32
) Adds a layer at the given position
toPosition
in the array. IftoPosition
is negative, the position is counted from the end, with-1
adding the layer at the end of the array.func clear(
) Clears all cells.
func clearLayer(Int32
) Clears all cells on the given layer.
func eraseCell(layer: Int32, coords: Vector2i
) Erases the cell on layer
layer
at coordinatescoords
.func fixInvalidTiles(
) Clears cells that do not exist in the tileset.
func forceUpdate(layer: Int32
) Forces the TileMap and the layer
layer
to update.func getCellAlternativeTile(layer: Int32, coords: Vector2i, useProxies: Bool
) -> Int32 Returns the tile alternative ID of the cell on layer
layer
atcoords
.func getCellAtlasCoords(layer: Int32, coords: Vector2i, useProxies: Bool
) -> Vector2i Returns the tile atlas coordinates ID of the cell on layer
layer
at coordinatescoords
. ReturnsVector2i(-1, -1)
if the cell does not exist.func getCellSourceId(layer: Int32, coords: Vector2i, useProxies: Bool
) -> Int32 Returns the tile source ID of the cell on layer
layer
at coordinatescoords
. Returns-1
if the cell does not exist.func getCellTileData(layer: Int32, coords: Vector2i, useProxies: Bool
) -> TileData? Returns the
TileData
object associated with the given cell, ornull
if the cell does not exist or is not aTileSetAtlasSource
.func getCoordsForBodyRid(body: RID
) -> Vector2i Returns the coordinates of the tile for given physics body RID. Such RID can be retrieved from
getColliderRid
, when colliding with a tile.func getLayerForBodyRid(body: RID
) -> Int32 Returns the tilemap layer of the tile for given physics body RID. Such RID can be retrieved from
getColliderRid
, when colliding with a tile.func getLayerModulate(layer: Int32
) -> Color Returns a TileMap layer’s modulate.
func getLayerName(layer: Int32
) -> String Returns a TileMap layer’s name.
func getLayerYSortOrigin(layer: Int32
) -> Int32 Returns a TileMap layer’s Y sort origin.
func getLayerZIndex(layer: Int32
) -> Int32 Returns a TileMap layer’s Z-index value.
func getLayersCount(
) -> Int32 Returns the number of layers in the TileMap.
func getNeighborCell(coords: Vector2i, neighbor: TileSet.CellNeighbor
) -> Vector2i Returns the neighboring cell to the one at coordinates
coords
, identified by theneighbor
direction. This method takes into account the different layouts a TileMap can take.func getPattern(layer: Int32, coordsArray: VariantCollection<Vector2i>
) -> TileMapPattern? Creates a new
TileMapPattern
from the given layer and set of cells.func getSurroundingCells(coords: Vector2i
) -> VariantCollection<Vector2i> Returns the list of all neighbourings cells to the one at
coords
.func getUsedCells(layer: Int32
) -> VariantCollection<Vector2i> Returns a
Vector2i
array with the positions of all cells containing a tile in the given layer. A cell is considered empty if its source identifier equals -1, its atlas coordinates identifiers isVector2(-1, -1)
and its alternative identifier is -1.func getUsedCellsById(layer: Int32, sourceId: Int32, atlasCoords: Vector2i, alternativeTile: Int32
) -> VariantCollection<Vector2i> Returns a
Vector2i
array with the positions of all cells containing a tile in the given layer. Tiles may be filtered according to their source (sourceId
), their atlas coordinates (atlasCoords
) or alternative id (alternativeTile
).func getUsedRect(
) -> Rect2i Returns a rectangle enclosing the used (non-empty) tiles of the map, including all layers.
func isLayerEnabled(layer: Int32
) -> Bool Returns if a layer is enabled.
func isLayerYSortEnabled(layer: Int32
) -> Bool Returns if a layer Y-sorts its tiles.
func localToMap(localPosition: Vector2
) -> Vector2i Returns the map coordinates of the cell containing the given
localPosition
. IflocalPosition
is in global coordinates, consider usingtoLocal(globalPoint:)
before passing it to this method. See alsomapToLocal(mapPosition:)
.func mapPattern(positionInTilemap: Vector2i, coordsInPattern: Vector2i, pattern: TileMapPattern?
) -> Vector2i Returns for the given coordinate
coordsInPattern
in aTileMapPattern
the corresponding cell coordinates if the pattern was pasted at thepositionInTilemap
coordinates (seesetPattern(layer:position:pattern:)
). This mapping is required as in half-offset tile shapes, the mapping might not work by calculatingposition_in_tile_map + coords_in_pattern
.func mapToLocal(mapPosition: Vector2i
) -> Vector2 Returns the centered position of a cell in the TileMap’s local coordinate space. To convert the returned value into global coordinates, use
toGlobal(localPoint:)
. See alsolocalToMap(localPosition:)
.func moveLayer(Int32, toPosition: Int32
) Moves the layer at index
layer
to the given positiontoPosition
in the array.func notifyRuntimeTileDataUpdate(layer: Int32
) Notifies the TileMap node that calls to
_useTileDataRuntimeUpdate(layer:coords:)
or_tileDataRuntimeUpdate(layer:coords:tileData:)
will lead to different results. This will thus trigger a TileMap update.func removeLayer(Int32
) Removes the layer at index
layer
.func setCell(layer: Int32, coords: Vector2i, sourceId: Int32, atlasCoords: Vector2i, alternativeTile: Int32
) Sets the tile identifiers for the cell on layer
layer
at coordinatescoords
. Each tile of theTileSet
is identified using three parts:func setCellsTerrainConnect(layer: Int32, cells: VariantCollection<Vector2i>, terrainSet: Int32, terrain: Int32, ignoreEmptyTerrains: Bool
) Update all the cells in the
cells
coordinates array so that they use the giventerrain
for the giventerrainSet
. If an updated cell has the same terrain as one of its neighboring cells, this function tries to join the two. This function might update neighboring tiles if needed to create correct terrain transitions.func setCellsTerrainPath(layer: Int32, path: VariantCollection<Vector2i>, terrainSet: Int32, terrain: Int32, ignoreEmptyTerrains: Bool
) Update all the cells in the
path
coordinates array so that they use the giventerrain
for the giventerrainSet
. The function will also connect two successive cell in the path with the same terrain. This function might update neighboring tiles if needed to create correct terrain transitions.func setLayerEnabled(layer: Int32, enabled: Bool
) Enables or disables the layer
layer
. A disabled layer is not processed at all (no rendering, no physics, etc.).func setLayerModulate(layer: Int32, modulate: Color
) Sets a layer’s color. It will be multiplied by tile’s color and TileMap’s modulate.
func setLayerName(layer: Int32, name: String
) Sets a layer’s name. This is mostly useful in the editor.
func setLayerYSortEnabled(layer: Int32, ySortEnabled: Bool
) Enables or disables a layer’s Y-sorting. If a layer is Y-sorted, the layer will behave as a CanvasItem node where each of its tile gets Y-sorted.
func setLayerYSortOrigin(layer: Int32, ySortOrigin: Int32
) Sets a layer’s Y-sort origin value. This Y-sort origin value is added to each tile’s Y-sort origin value.
func setLayerZIndex(layer: Int32, zIndex: Int32
) Sets a layers Z-index value. This Z-index is added to each tile’s Z-index value.
func setPattern(layer: Int32, position: Vector2i, pattern: TileMapPattern?
) Paste the given
TileMapPattern
at the givenposition
andlayer
in the tile map.func updateInternals(
) Triggers a direct update of the TileMap. Usually, calling this function is not needed, as TileMap node updates automatically when one of its properties or cells is modified.
Show implementation details (2)
Hide implementation details
func _tileDataRuntimeUpdate(layer: Int32, coords: Vector2i, tileData: TileData?
) Called with a TileData object about to be used internally by the TileMap, allowing its modification at runtime.
func _useTileDataRuntimeUpdate(layer: Int32, coords: Vector2i
) -> Bool Should return
true
if the tile at coordinatescoords
on layerlayer
requires a runtime update.
Citizens in SwiftGodot
Conformances
protocol CaseIterable
A type that provides a collection of all of its values.
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol RawRepresentable<RawValue>
A type that can be converted to and from an associated raw value.
Type members
Instance members
var debugDescription: String
A textual representation of this instance, suitable for debugging
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.