class_tilemap.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the TileMap.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_TileMap:
  5. TileMap
  6. =======
  7. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Node for 2D tile-based maps.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`clear<class_TileMap_clear>` **(** **)** |
  16. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`int<class_int>` | :ref:`get_cell<class_TileMap_get_cell>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  18. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`int<class_int>` | :ref:`get_cellv<class_TileMap_get_cellv>` **(** :ref:`Vector2<class_vector2>` position **)** const |
  20. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_bit<class_TileMap_get_collision_layer_bit>` **(** :ref:`int<class_int>` bit **)** const |
  22. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_bit<class_TileMap_get_collision_mask_bit>` **(** :ref:`int<class_int>` bit **)** const |
  24. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Array<class_array>` | :ref:`get_used_cells<class_TileMap_get_used_cells>` **(** **)** const |
  26. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Array<class_array>` | :ref:`get_used_cells_by_id<class_TileMap_get_used_cells_by_id>` **(** :ref:`int<class_int>` id **)** const |
  28. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Rect2<class_rect2>` | :ref:`get_used_rect<class_TileMap_get_used_rect>` **(** **)** |
  30. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`is_cell_transposed<class_TileMap_is_cell_transposed>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  32. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`is_cell_x_flipped<class_TileMap_is_cell_x_flipped>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  34. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`is_cell_y_flipped<class_TileMap_is_cell_y_flipped>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  36. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Vector2<class_vector2>` | :ref:`map_to_world<class_TileMap_map_to_world>` **(** :ref:`Vector2<class_vector2>` map_position, :ref:`bool<class_bool>` ignore_half_ofs=false **)** const |
  38. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_cell<class_TileMap_set_cell>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` tile, :ref:`bool<class_bool>` flip_x=false, :ref:`bool<class_bool>` flip_y=false, :ref:`bool<class_bool>` transpose=false, :ref:`Vector2<class_vector2>` autotile_coord=Vector2( 0, 0 ) **)** |
  40. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_cellv<class_TileMap_set_cellv>` **(** :ref:`Vector2<class_vector2>` position, :ref:`int<class_int>` tile, :ref:`bool<class_bool>` flip_x=false, :ref:`bool<class_bool>` flip_y=false, :ref:`bool<class_bool>` transpose=false **)** |
  42. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`set_collision_layer_bit<class_TileMap_set_collision_layer_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  44. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_collision_mask_bit<class_TileMap_set_collision_mask_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  46. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`update_bitmask_area<class_TileMap_update_bitmask_area>` **(** :ref:`Vector2<class_vector2>` position **)** |
  48. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`update_bitmask_region<class_TileMap_update_bitmask_region>` **(** :ref:`Vector2<class_vector2>` start=Vector2( 0, 0 ), :ref:`Vector2<class_vector2>` end=Vector2( 0, 0 ) **)** |
  50. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Vector2<class_vector2>` | :ref:`world_to_map<class_TileMap_world_to_map>` **(** :ref:`Vector2<class_vector2>` world_position **)** const |
  52. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. Signals
  54. -------
  55. .. _class_TileMap_settings_changed:
  56. - **settings_changed** **(** **)**
  57. Emitted when a tilemap setting has changed.
  58. Member Variables
  59. ----------------
  60. .. _class_TileMap_cell_clip_uv:
  61. - :ref:`bool<class_bool>` **cell_clip_uv**
  62. .. _class_TileMap_cell_custom_transform:
  63. - :ref:`Transform2D<class_transform2d>` **cell_custom_transform** - The custom :ref:`Transform2D<class_transform2d>` to be applied to the TileMap's cells.
  64. .. _class_TileMap_cell_half_offset:
  65. - :ref:`HalfOffset<enum_tilemap_halfoffset>` **cell_half_offset** - Amount to offset alternating tiles. Uses HALF_OFFSET\_\* constants. Default value: HALF_OFFSET_DISABLED.
  66. .. _class_TileMap_cell_quadrant_size:
  67. - :ref:`int<class_int>` **cell_quadrant_size** - The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size. Default value: 16.
  68. .. _class_TileMap_cell_size:
  69. - :ref:`Vector2<class_vector2>` **cell_size** - The TileMap's cell size.
  70. .. _class_TileMap_cell_tile_origin:
  71. - :ref:`TileOrigin<enum_tilemap_tileorigin>` **cell_tile_origin** - Position for tile origin. Uses TILE_ORIGIN\_\* constants. Default value: TILE_ORIGIN_TOP_LEFT.
  72. .. _class_TileMap_cell_y_sort:
  73. - :ref:`bool<class_bool>` **cell_y_sort** - If ``true`` the TileMap's children will be drawn in order of their Y coordinate. Default value: ``false``.
  74. .. _class_TileMap_collision_bounce:
  75. - :ref:`float<class_float>` **collision_bounce** - Bounce value for static body collisions (see ``collision_use_kinematic``). Default value: 0.
  76. .. _class_TileMap_collision_friction:
  77. - :ref:`float<class_float>` **collision_friction** - Friction value for static body collisions (see ``collision_use_kinematic``). Default value: 1.
  78. .. _class_TileMap_collision_layer:
  79. - :ref:`int<class_int>` **collision_layer** - The collision layer(s) for all colliders in the TileMap.
  80. .. _class_TileMap_collision_mask:
  81. - :ref:`int<class_int>` **collision_mask** - The collision mask(s) for all colliders in the TileMap.
  82. .. _class_TileMap_collision_use_kinematic:
  83. - :ref:`bool<class_bool>` **collision_use_kinematic** - If ``true`` TileMap collisions will be handled as a kinematic body. If ``false`` collisions will be handled as static body. Default value: ``false``.
  84. .. _class_TileMap_mode:
  85. - :ref:`Mode<enum_tilemap_mode>` **mode** - The TileMap orientation mode. Uses MODE\_\* constants. Default value: MODE_SQUARE.
  86. .. _class_TileMap_occluder_light_mask:
  87. - :ref:`int<class_int>` **occluder_light_mask** - 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).
  88. .. _class_TileMap_tile_set:
  89. - :ref:`TileSet<class_tileset>` **tile_set** - The assigned :ref:`TileSet<class_tileset>`.
  90. Numeric Constants
  91. -----------------
  92. - **INVALID_CELL** = **-1** --- Returned when a cell doesn't exist.
  93. Enums
  94. -----
  95. .. _enum_TileMap_HalfOffset:
  96. enum **HalfOffset**
  97. - **HALF_OFFSET_X** = **0** --- Half offset on the X coordinate.
  98. - **HALF_OFFSET_Y** = **1** --- Half offset on the Y coordinate.
  99. - **HALF_OFFSET_DISABLED** = **2** --- Half offset disabled.
  100. .. _enum_TileMap_TileOrigin:
  101. enum **TileOrigin**
  102. - **TILE_ORIGIN_TOP_LEFT** = **0** --- Tile origin at its top-left corner.
  103. - **TILE_ORIGIN_CENTER** = **1** --- Tile origin at its center.
  104. - **TILE_ORIGIN_BOTTOM_LEFT** = **2** --- Tile origin at its bottom-left corner.
  105. .. _enum_TileMap_Mode:
  106. enum **Mode**
  107. - **MODE_SQUARE** = **0** --- Orthogonal orientation mode.
  108. - **MODE_ISOMETRIC** = **1** --- Isometric orientation mode.
  109. - **MODE_CUSTOM** = **2** --- Custom orientation mode.
  110. Description
  111. -----------
  112. Node for 2D tile-based maps. Tilemaps use a :ref:`TileSet<class_tileset>` which contain a list of tiles (textures plus optional collision, navigation, and/or occluder shapes) which are used to create grid-based maps.
  113. Member Function Description
  114. ---------------------------
  115. .. _class_TileMap_clear:
  116. - void **clear** **(** **)**
  117. Clear all cells.
  118. .. _class_TileMap_get_cell:
  119. - :ref:`int<class_int>` **get_cell** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  120. Return the tile index of the referenced cell.
  121. .. _class_TileMap_get_cellv:
  122. - :ref:`int<class_int>` **get_cellv** **(** :ref:`Vector2<class_vector2>` position **)** const
  123. Return the tile index of the cell referenced by a Vector2.
  124. .. _class_TileMap_get_collision_layer_bit:
  125. - :ref:`bool<class_bool>` **get_collision_layer_bit** **(** :ref:`int<class_int>` bit **)** const
  126. .. _class_TileMap_get_collision_mask_bit:
  127. - :ref:`bool<class_bool>` **get_collision_mask_bit** **(** :ref:`int<class_int>` bit **)** const
  128. .. _class_TileMap_get_used_cells:
  129. - :ref:`Array<class_array>` **get_used_cells** **(** **)** const
  130. Return an array of all cells containing a tile from the tileset (i.e. a tile index different from -1).
  131. .. _class_TileMap_get_used_cells_by_id:
  132. - :ref:`Array<class_array>` **get_used_cells_by_id** **(** :ref:`int<class_int>` id **)** const
  133. .. _class_TileMap_get_used_rect:
  134. - :ref:`Rect2<class_rect2>` **get_used_rect** **(** **)**
  135. .. _class_TileMap_is_cell_transposed:
  136. - :ref:`bool<class_bool>` **is_cell_transposed** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  137. Return whether the referenced cell is transposed, i.e. the X and Y axes are swapped (mirroring with regard to the (1,1) vector).
  138. .. _class_TileMap_is_cell_x_flipped:
  139. - :ref:`bool<class_bool>` **is_cell_x_flipped** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  140. Return whether the referenced cell is flipped over the X axis.
  141. .. _class_TileMap_is_cell_y_flipped:
  142. - :ref:`bool<class_bool>` **is_cell_y_flipped** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  143. Return whether the referenced cell is flipped over the Y axis.
  144. .. _class_TileMap_map_to_world:
  145. - :ref:`Vector2<class_vector2>` **map_to_world** **(** :ref:`Vector2<class_vector2>` map_position, :ref:`bool<class_bool>` ignore_half_ofs=false **)** const
  146. Return the absolute world position corresponding to the tilemap (grid-based) coordinates given as an argument.
  147. Optionally, the tilemap's potential half offset can be ignored.
  148. .. _class_TileMap_set_cell:
  149. - void **set_cell** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` tile, :ref:`bool<class_bool>` flip_x=false, :ref:`bool<class_bool>` flip_y=false, :ref:`bool<class_bool>` transpose=false, :ref:`Vector2<class_vector2>` autotile_coord=Vector2( 0, 0 ) **)**
  150. Set the tile index for the cell referenced by its grid-based X and Y coordinates.
  151. A tile index of -1 clears the cell.
  152. Optionally, the tile can also be flipped over the X and Y coordinates, transposed, or be given autotile coordinates.
  153. .. _class_TileMap_set_cellv:
  154. - void **set_cellv** **(** :ref:`Vector2<class_vector2>` position, :ref:`int<class_int>` tile, :ref:`bool<class_bool>` flip_x=false, :ref:`bool<class_bool>` flip_y=false, :ref:`bool<class_bool>` transpose=false **)**
  155. Set the tile index for the cell referenced by a Vector2 of grid-based coordinates.
  156. A tile index of -1 clears the cell.
  157. Optionally, the tile can also be flipped over the X and Y axes or transposed.
  158. .. _class_TileMap_set_collision_layer_bit:
  159. - void **set_collision_layer_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  160. Set any collision layer to be ``true`` or ``false``.
  161. .. _class_TileMap_set_collision_mask_bit:
  162. - void **set_collision_mask_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  163. .. _class_TileMap_update_bitmask_area:
  164. - void **update_bitmask_area** **(** :ref:`Vector2<class_vector2>` position **)**
  165. Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based X and Y coordinates.
  166. .. _class_TileMap_update_bitmask_region:
  167. - void **update_bitmask_region** **(** :ref:`Vector2<class_vector2>` start=Vector2( 0, 0 ), :ref:`Vector2<class_vector2>` end=Vector2( 0, 0 ) **)**
  168. Applies autotiling rules to the cells in the given region (specified by grid-based X and Y coordinates).
  169. Calling with invalid (or missing) parameters applies autotiling rules for the entire TileMap.
  170. .. _class_TileMap_world_to_map:
  171. - :ref:`Vector2<class_vector2>` **world_to_map** **(** :ref:`Vector2<class_vector2>` world_position **)** const
  172. Return the tilemap (grid-based) coordinates corresponding to the absolute world position given as an argument.