class_tilemap - vkbsb/godot GitHub Wiki

TileMap

####Inherits: Node2D ####Category: Core

Brief Description

Node for 2D Tile-Based games.

Member Functions

Signals

  • settings_changed ( )

Numeric Constants

  • INVALID_CELL = -1 - Returned when a cell doesn't exist.
  • MODE_SQUARE = 0
  • MODE_ISOMETRIC = 1
  • MODE_CUSTOM = 2
  • HALF_OFFSET_X = 0
  • HALF_OFFSET_Y = 1
  • HALF_OFFSET_DISABLED = 2

Description

Node for 2D Tile-Based games. Tilemaps use a TileSet which contain a list of tiles (textures, their rect and a collision) and are used to create complex grid-based maps. To optimize drawing and culling (sort of like GridMap), you can specify a quadrant size, so chunks of the map will be batched together the time of drawing.

Member Function Description

set_tileset

  • void set_tileset ( TileSet tileset )

Set the current tileset.

get_tileset

Return the current tileset.

set_cell_size

  • void set_cell_size ( Vector2 size )

Set the cell size.

get_cell_size

Return the cell size.

set_quadrant_size

  • void set_quadrant_size ( int size )

Set the quadrant size, this optimizes drawing by batching chunks of map at draw/cull time.

get_quadrant_size

  • int get_quadrant_size ( ) const

Return the quadrant size, this optimizes drawing by batching chunks of map at draw/cull time.

set_center_x

  • void set_center_x ( bool enable )

Set tiles to be centered in x coordinate. (by default this is false and they are drawn from upper left cell corner).

get_center_x

  • bool get_center_x ( ) const

Return true if tiles are to be centered in x coordinate (by default this is false and they are drawn from upper left cell corner).

set_center_y

  • void set_center_y ( bool enable )

Set tiles to be centered in y coordinate. (by default this is false and they are drawn from upper left cell corner).

get_center_y

  • bool get_center_y ( ) const

Return true if tiles are to be centered in y coordinate (by default this is false and they are drawn from upper left cell corner).

set_cell

Set the contents of a cell. Cells can be optionally flipped in y or x.

get_cell

Return the contents of a cell.

is_cell_x_flipped

Return if a given cell is flipped in x axis.

is_cell_y_flipped

Return if a given cell is flipped in y axis.

clear

  • void clear ( )

Clear all cells.