Enumerationmigueldeicaza.swiftgodot 0.46.0SwiftGodot
DebugVisibilityMode
TileMapLayer.swift:29enum DebugVisibilityMode
Cases
case `default`
Hide the collisions or navigation debug shapes in the editor, and use the debug settings to determine their visibility in game (i.e.
debugCollisionsHint
ordebugNavigationHint
).case forceHide
Always hide the collisions or navigation debug shapes.
case forceShow
Always show the collisions or navigation debug shapes.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (41) members.
Type members
Instance members
var changed: SimpleSignal
Emitted when this
TileMapLayer
’s properties changes. This includes modified cells, properties, or changes made to its assignedTileSet
.var collisionEnabled: Bool
Enable or disable collisions.
var collisionVisibilityMode: TileMapLayer.DebugVisibilityMode
Show or hide the
TileMapLayer
’s collision shapes. If set to .default
, this depends on the show collision debug settings.var enabled: Bool
If
false
, disables thisTileMapLayer
completely (rendering, collision, navigation, scene tiles, etc.)var renderingQuadrantSize: Int32
The
TileMapLayer
‘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 tileMapData: PackedByteArray
The raw tile map data as a byte array.
var tileSet: TileSet?
The
TileSet
used by this layer. The textures, collisions, and additional behavior of all available tiles are stored here.var useKinematicBodies: Bool
If
true
, thisTileMapLayer
collision shapes will be instantiated as kinematic bodies. This can be needed for movingTileMapLayer
nodes (i.e. moving platforms).var xDrawOrderReversed: Bool
If
ySortEnabled
is enabled, setting this totrue
will reverse the order the tiles are drawn on the X-axis.var ySortOrigin: Int32
This Y-sort origin value is added to each tile’s Y-sort origin value. This allows, for example, to fake a different height level. This can be useful for top-down view games.
func clear(
) Clears all cells.
func eraseCell(coords: Vector2i
) Erases the cell at coordinates
coords
.func fixInvalidTiles(
) Clears cells containing tiles that do not exist in the
tileSet
.func getCellAlternativeTile(coords: Vector2i
) -> Int32 Returns the tile alternative ID of the cell at coordinates
coords
.func getCellAtlasCoords(Vector2i
) -> Vector2i Returns the tile atlas coordinates ID of the cell at coordinates
coords
. ReturnsVector2i(-1, -1)
if the cell does not exist.func getCellSourceId(coords: Vector2i
) -> Int32 Returns the tile source ID of the cell at coordinates
coords
. Returns-1
if the cell does not exist.func getCellTileData(coords: Vector2i
) -> 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 anRID
can be retrieved fromgetColliderRid
, when colliding with a tile.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(coordsArray: VariantCollection<Vector2i>
) -> TileMapPattern? Creates and returns a new
TileMapPattern
from the given array of cells. See alsosetPattern(position:pattern:)
.func getSurroundingCells(coords: Vector2i
) -> VariantCollection<Vector2i> Returns the list of all neighboring cells to the one at
coords
.func getUsedCells(
) -> VariantCollection<Vector2i> Returns a
Vector2i
array with the positions of all cells containing a tile. A cell is considered empty if its source identifier equals-1
, its atlas coordinate identifier isVector2(-1, -1)
and its alternative identifier is-1
.func getUsedCellsById(sourceId: Int32, atlasCoords: Vector2i, alternativeTile: Int32
) -> VariantCollection<Vector2i> Returns a
Vector2i
array with the positions of all cells containing a tile. 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.
func hasBodyRid(body: RID
) -> Bool Returns whether the provided
body
RID
belongs to one of thisTileMapLayer
’s cells.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 coordinates
coordsInPattern
in aTileMapPattern
the corresponding cell coordinates if the pattern was pasted at thepositionInTilemap
coordinates (seesetPattern(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
TileMapLayer
’s local coordinate space. To convert the returned value into global coordinates, usetoGlobal(localPoint:)
. See alsolocalToMap(localPosition:)
.func notifyRuntimeTileDataUpdate(
) Notifies the
TileMapLayer
node that calls to_useTileDataRuntimeUpdate(coords:)
or_tileDataRuntimeUpdate(coords:tileData:)
will lead to different results. This will thus trigger aTileMapLayer
update.func setCell(coords: Vector2i, sourceId: Int32, atlasCoords: Vector2i, alternativeTile: Int32
) Sets the tile identifiers for the cell at coordinates
coords
. Each tile of theTileSet
is identified using three parts:func setCellsTerrainConnect(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(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 setPattern(position: Vector2i, pattern: TileMapPattern?
) Pastes the
TileMapPattern
at the givenposition
in the tile map. See alsogetPattern(coordsArray:)
.func updateInternals(
) Triggers a direct update of the
TileMapLayer
. Usually, calling this function is not needed, asTileMapLayer
node updates automatically when one of its properties or cells is modified.
Show implementation details (2)
Hide implementation details
func _tileDataRuntimeUpdate(coords: Vector2i, tileData: TileData?
) Called with a
TileData
object about to be used internally by theTileMapLayer
, allowing its modification at runtime.func _useTileDataRuntimeUpdate(coords: Vector2i
) -> Bool Should return
true
if the tile at coordinatescoords
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.