class_tilemap.rst 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the TileMap.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_TileMap:
  6. TileMap
  7. =======
  8. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Node for 2D tile-based maps.
  13. Properties
  14. ----------
  15. +--------------------------------------------+--------------------------------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`cell_clip_uv<class_TileMap_property_cell_clip_uv>` |
  17. +--------------------------------------------+--------------------------------------------------------------------------------+
  18. | :ref:`Transform2D<class_Transform2D>` | :ref:`cell_custom_transform<class_TileMap_property_cell_custom_transform>` |
  19. +--------------------------------------------+--------------------------------------------------------------------------------+
  20. | :ref:`HalfOffset<enum_TileMap_HalfOffset>` | :ref:`cell_half_offset<class_TileMap_property_cell_half_offset>` |
  21. +--------------------------------------------+--------------------------------------------------------------------------------+
  22. | :ref:`int<class_int>` | :ref:`cell_quadrant_size<class_TileMap_property_cell_quadrant_size>` |
  23. +--------------------------------------------+--------------------------------------------------------------------------------+
  24. | :ref:`Vector2<class_Vector2>` | :ref:`cell_size<class_TileMap_property_cell_size>` |
  25. +--------------------------------------------+--------------------------------------------------------------------------------+
  26. | :ref:`TileOrigin<enum_TileMap_TileOrigin>` | :ref:`cell_tile_origin<class_TileMap_property_cell_tile_origin>` |
  27. +--------------------------------------------+--------------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | :ref:`cell_y_sort<class_TileMap_property_cell_y_sort>` |
  29. +--------------------------------------------+--------------------------------------------------------------------------------+
  30. | :ref:`float<class_float>` | :ref:`collision_bounce<class_TileMap_property_collision_bounce>` |
  31. +--------------------------------------------+--------------------------------------------------------------------------------+
  32. | :ref:`float<class_float>` | :ref:`collision_friction<class_TileMap_property_collision_friction>` |
  33. +--------------------------------------------+--------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`collision_layer<class_TileMap_property_collision_layer>` |
  35. +--------------------------------------------+--------------------------------------------------------------------------------+
  36. | :ref:`int<class_int>` | :ref:`collision_mask<class_TileMap_property_collision_mask>` |
  37. +--------------------------------------------+--------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`collision_use_kinematic<class_TileMap_property_collision_use_kinematic>` |
  39. +--------------------------------------------+--------------------------------------------------------------------------------+
  40. | :ref:`Mode<enum_TileMap_Mode>` | :ref:`mode<class_TileMap_property_mode>` |
  41. +--------------------------------------------+--------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`occluder_light_mask<class_TileMap_property_occluder_light_mask>` |
  43. +--------------------------------------------+--------------------------------------------------------------------------------+
  44. | :ref:`TileSet<class_TileSet>` | :ref:`tile_set<class_TileMap_property_tile_set>` |
  45. +--------------------------------------------+--------------------------------------------------------------------------------+
  46. Methods
  47. -------
  48. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`clear<class_TileMap_method_clear>` **(** **)** |
  50. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`fix_invalid_tiles<class_TileMap_method_fix_invalid_tiles>` **(** **)** |
  52. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`get_cell<class_TileMap_method_get_cell>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  54. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Vector2<class_Vector2>` | :ref:`get_cell_autotile_coord<class_TileMap_method_get_cell_autotile_coord>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  56. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`get_cellv<class_TileMap_method_get_cellv>` **(** :ref:`Vector2<class_Vector2>` position **)** const |
  58. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_bit<class_TileMap_method_get_collision_layer_bit>` **(** :ref:`int<class_int>` bit **)** const |
  60. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_bit<class_TileMap_method_get_collision_mask_bit>` **(** :ref:`int<class_int>` bit **)** const |
  62. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`Array<class_Array>` | :ref:`get_used_cells<class_TileMap_method_get_used_cells>` **(** **)** const |
  64. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`Array<class_Array>` | :ref:`get_used_cells_by_id<class_TileMap_method_get_used_cells_by_id>` **(** :ref:`int<class_int>` id **)** const |
  66. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`Rect2<class_Rect2>` | :ref:`get_used_rect<class_TileMap_method_get_used_rect>` **(** **)** |
  68. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`bool<class_bool>` | :ref:`is_cell_transposed<class_TileMap_method_is_cell_transposed>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  70. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`bool<class_bool>` | :ref:`is_cell_x_flipped<class_TileMap_method_is_cell_x_flipped>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  72. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`is_cell_y_flipped<class_TileMap_method_is_cell_y_flipped>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  74. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`Vector2<class_Vector2>` | :ref:`map_to_world<class_TileMap_method_map_to_world>` **(** :ref:`Vector2<class_Vector2>` map_position, :ref:`bool<class_bool>` ignore_half_ofs=false **)** const |
  76. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`set_cell<class_TileMap_method_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 ) **)** |
  78. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`set_cellv<class_TileMap_method_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 **)** |
  80. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`set_collision_layer_bit<class_TileMap_method_set_collision_layer_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  82. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`set_collision_mask_bit<class_TileMap_method_set_collision_mask_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  84. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`update_bitmask_area<class_TileMap_method_update_bitmask_area>` **(** :ref:`Vector2<class_Vector2>` position **)** |
  86. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`update_bitmask_region<class_TileMap_method_update_bitmask_region>` **(** :ref:`Vector2<class_Vector2>` start=Vector2( 0, 0 ), :ref:`Vector2<class_Vector2>` end=Vector2( 0, 0 ) **)** |
  88. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`update_dirty_quadrants<class_TileMap_method_update_dirty_quadrants>` **(** **)** |
  90. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`Vector2<class_Vector2>` | :ref:`world_to_map<class_TileMap_method_world_to_map>` **(** :ref:`Vector2<class_Vector2>` world_position **)** const |
  92. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. Signals
  94. -------
  95. .. _class_TileMap_signal_settings_changed:
  96. - **settings_changed** **(** **)**
  97. Emitted when a tilemap setting has changed.
  98. Enumerations
  99. ------------
  100. .. _enum_TileMap_Mode:
  101. .. _class_TileMap_constant_MODE_SQUARE:
  102. .. _class_TileMap_constant_MODE_ISOMETRIC:
  103. .. _class_TileMap_constant_MODE_CUSTOM:
  104. enum **Mode**:
  105. - **MODE_SQUARE** = **0** --- Orthogonal orientation mode.
  106. - **MODE_ISOMETRIC** = **1** --- Isometric orientation mode.
  107. - **MODE_CUSTOM** = **2** --- Custom orientation mode.
  108. ----
  109. .. _enum_TileMap_HalfOffset:
  110. .. _class_TileMap_constant_HALF_OFFSET_X:
  111. .. _class_TileMap_constant_HALF_OFFSET_Y:
  112. .. _class_TileMap_constant_HALF_OFFSET_DISABLED:
  113. .. _class_TileMap_constant_HALF_OFFSET_NEGATIVE_X:
  114. .. _class_TileMap_constant_HALF_OFFSET_NEGATIVE_Y:
  115. enum **HalfOffset**:
  116. - **HALF_OFFSET_X** = **0** --- Half offset on the X coordinate.
  117. - **HALF_OFFSET_Y** = **1** --- Half offset on the Y coordinate.
  118. - **HALF_OFFSET_DISABLED** = **2** --- Half offset disabled.
  119. - **HALF_OFFSET_NEGATIVE_X** = **3** --- Half offset on the X coordinate (negative).
  120. - **HALF_OFFSET_NEGATIVE_Y** = **4** --- Half offset on the Y coordinate (negative).
  121. ----
  122. .. _enum_TileMap_TileOrigin:
  123. .. _class_TileMap_constant_TILE_ORIGIN_TOP_LEFT:
  124. .. _class_TileMap_constant_TILE_ORIGIN_CENTER:
  125. .. _class_TileMap_constant_TILE_ORIGIN_BOTTOM_LEFT:
  126. enum **TileOrigin**:
  127. - **TILE_ORIGIN_TOP_LEFT** = **0** --- Tile origin at its top-left corner.
  128. - **TILE_ORIGIN_CENTER** = **1** --- Tile origin at its center.
  129. - **TILE_ORIGIN_BOTTOM_LEFT** = **2** --- Tile origin at its bottom-left corner.
  130. Constants
  131. ---------
  132. .. _class_TileMap_constant_INVALID_CELL:
  133. - **INVALID_CELL** = **-1** --- Returned when a cell doesn't exist.
  134. Description
  135. -----------
  136. 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.
  137. Tutorials
  138. ---------
  139. - :doc:`../tutorials/2d/using_tilemaps`
  140. Property Descriptions
  141. ---------------------
  142. .. _class_TileMap_property_cell_clip_uv:
  143. - :ref:`bool<class_bool>` **cell_clip_uv**
  144. +----------+--------------------+
  145. | *Setter* | set_clip_uv(value) |
  146. +----------+--------------------+
  147. | *Getter* | get_clip_uv() |
  148. +----------+--------------------+
  149. ----
  150. .. _class_TileMap_property_cell_custom_transform:
  151. - :ref:`Transform2D<class_Transform2D>` **cell_custom_transform**
  152. +----------+-----------------------------+
  153. | *Setter* | set_custom_transform(value) |
  154. +----------+-----------------------------+
  155. | *Getter* | get_custom_transform() |
  156. +----------+-----------------------------+
  157. The custom :ref:`Transform2D<class_Transform2D>` to be applied to the TileMap's cells.
  158. ----
  159. .. _class_TileMap_property_cell_half_offset:
  160. - :ref:`HalfOffset<enum_TileMap_HalfOffset>` **cell_half_offset**
  161. +----------+------------------------+
  162. | *Setter* | set_half_offset(value) |
  163. +----------+------------------------+
  164. | *Getter* | get_half_offset() |
  165. +----------+------------------------+
  166. Amount to offset alternating tiles. Uses HALF_OFFSET\_\* constants. Default value: HALF_OFFSET_DISABLED.
  167. ----
  168. .. _class_TileMap_property_cell_quadrant_size:
  169. - :ref:`int<class_int>` **cell_quadrant_size**
  170. +----------+--------------------------+
  171. | *Setter* | set_quadrant_size(value) |
  172. +----------+--------------------------+
  173. | *Getter* | get_quadrant_size() |
  174. +----------+--------------------------+
  175. The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size. Default value: 16.
  176. ----
  177. .. _class_TileMap_property_cell_size:
  178. - :ref:`Vector2<class_Vector2>` **cell_size**
  179. +----------+----------------------+
  180. | *Setter* | set_cell_size(value) |
  181. +----------+----------------------+
  182. | *Getter* | get_cell_size() |
  183. +----------+----------------------+
  184. The TileMap's cell size.
  185. ----
  186. .. _class_TileMap_property_cell_tile_origin:
  187. - :ref:`TileOrigin<enum_TileMap_TileOrigin>` **cell_tile_origin**
  188. +----------+------------------------+
  189. | *Setter* | set_tile_origin(value) |
  190. +----------+------------------------+
  191. | *Getter* | get_tile_origin() |
  192. +----------+------------------------+
  193. Position for tile origin. Uses TILE_ORIGIN\_\* constants. Default value: TILE_ORIGIN_TOP_LEFT.
  194. ----
  195. .. _class_TileMap_property_cell_y_sort:
  196. - :ref:`bool<class_bool>` **cell_y_sort**
  197. +----------+--------------------------+
  198. | *Setter* | set_y_sort_mode(value) |
  199. +----------+--------------------------+
  200. | *Getter* | is_y_sort_mode_enabled() |
  201. +----------+--------------------------+
  202. If ``true``, the TileMap's children will be drawn in order of their Y coordinate. Default value: ``false``.
  203. ----
  204. .. _class_TileMap_property_collision_bounce:
  205. - :ref:`float<class_float>` **collision_bounce**
  206. +----------+-----------------------------+
  207. | *Setter* | set_collision_bounce(value) |
  208. +----------+-----------------------------+
  209. | *Getter* | get_collision_bounce() |
  210. +----------+-----------------------------+
  211. Bounce value for static body collisions (see ``collision_use_kinematic``). Default value: 0.
  212. ----
  213. .. _class_TileMap_property_collision_friction:
  214. - :ref:`float<class_float>` **collision_friction**
  215. +----------+-------------------------------+
  216. | *Setter* | set_collision_friction(value) |
  217. +----------+-------------------------------+
  218. | *Getter* | get_collision_friction() |
  219. +----------+-------------------------------+
  220. Friction value for static body collisions (see ``collision_use_kinematic``). Default value: 1.
  221. ----
  222. .. _class_TileMap_property_collision_layer:
  223. - :ref:`int<class_int>` **collision_layer**
  224. +----------+----------------------------+
  225. | *Setter* | set_collision_layer(value) |
  226. +----------+----------------------------+
  227. | *Getter* | get_collision_layer() |
  228. +----------+----------------------------+
  229. The collision layer(s) for all colliders in the TileMap.
  230. ----
  231. .. _class_TileMap_property_collision_mask:
  232. - :ref:`int<class_int>` **collision_mask**
  233. +----------+---------------------------+
  234. | *Setter* | set_collision_mask(value) |
  235. +----------+---------------------------+
  236. | *Getter* | get_collision_mask() |
  237. +----------+---------------------------+
  238. The collision mask(s) for all colliders in the TileMap.
  239. ----
  240. .. _class_TileMap_property_collision_use_kinematic:
  241. - :ref:`bool<class_bool>` **collision_use_kinematic**
  242. +----------+------------------------------------+
  243. | *Setter* | set_collision_use_kinematic(value) |
  244. +----------+------------------------------------+
  245. | *Getter* | get_collision_use_kinematic() |
  246. +----------+------------------------------------+
  247. If ``true``, TileMap collisions will be handled as a kinematic body. If ``false``, collisions will be handled as static body. Default value: ``false``.
  248. ----
  249. .. _class_TileMap_property_mode:
  250. - :ref:`Mode<enum_TileMap_Mode>` **mode**
  251. +----------+-----------------+
  252. | *Setter* | set_mode(value) |
  253. +----------+-----------------+
  254. | *Getter* | get_mode() |
  255. +----------+-----------------+
  256. The TileMap orientation mode. Uses MODE\_\* constants. Default value: MODE_SQUARE.
  257. ----
  258. .. _class_TileMap_property_occluder_light_mask:
  259. - :ref:`int<class_int>` **occluder_light_mask**
  260. +----------+--------------------------------+
  261. | *Setter* | set_occluder_light_mask(value) |
  262. +----------+--------------------------------+
  263. | *Getter* | get_occluder_light_mask() |
  264. +----------+--------------------------------+
  265. 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).
  266. ----
  267. .. _class_TileMap_property_tile_set:
  268. - :ref:`TileSet<class_TileSet>` **tile_set**
  269. +----------+--------------------+
  270. | *Setter* | set_tileset(value) |
  271. +----------+--------------------+
  272. | *Getter* | get_tileset() |
  273. +----------+--------------------+
  274. The assigned :ref:`TileSet<class_TileSet>`.
  275. Method Descriptions
  276. -------------------
  277. .. _class_TileMap_method_clear:
  278. - void **clear** **(** **)**
  279. Clears all cells.
  280. ----
  281. .. _class_TileMap_method_fix_invalid_tiles:
  282. - void **fix_invalid_tiles** **(** **)**
  283. Clears cells that do not exist in the tileset.
  284. ----
  285. .. _class_TileMap_method_get_cell:
  286. - :ref:`int<class_int>` **get_cell** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  287. Returns the tile index of the given cell. If no tile exists in the cell, returns :ref:`INVALID_CELL<class_TileMap_constant_INVALID_CELL>`.
  288. ----
  289. .. _class_TileMap_method_get_cell_autotile_coord:
  290. - :ref:`Vector2<class_Vector2>` **get_cell_autotile_coord** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  291. ----
  292. .. _class_TileMap_method_get_cellv:
  293. - :ref:`int<class_int>` **get_cellv** **(** :ref:`Vector2<class_Vector2>` position **)** const
  294. Returns the tile index of the cell given by a Vector2. If no tile exists in the cell, returns :ref:`INVALID_CELL<class_TileMap_constant_INVALID_CELL>`.
  295. ----
  296. .. _class_TileMap_method_get_collision_layer_bit:
  297. - :ref:`bool<class_bool>` **get_collision_layer_bit** **(** :ref:`int<class_int>` bit **)** const
  298. Returns ``true`` if the given collision layer bit is set.
  299. ----
  300. .. _class_TileMap_method_get_collision_mask_bit:
  301. - :ref:`bool<class_bool>` **get_collision_mask_bit** **(** :ref:`int<class_int>` bit **)** const
  302. Returns ``true`` if the given collision mask bit is set.
  303. ----
  304. .. _class_TileMap_method_get_used_cells:
  305. - :ref:`Array<class_Array>` **get_used_cells** **(** **)** const
  306. Returns a :ref:`Vector2<class_Vector2>` array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from ``-1``).
  307. ----
  308. .. _class_TileMap_method_get_used_cells_by_id:
  309. - :ref:`Array<class_Array>` **get_used_cells_by_id** **(** :ref:`int<class_int>` id **)** const
  310. Returns an array of all cells with the given tile id.
  311. ----
  312. .. _class_TileMap_method_get_used_rect:
  313. - :ref:`Rect2<class_Rect2>` **get_used_rect** **(** **)**
  314. Returns a rectangle enclosing the used (non-empty) tiles of the map.
  315. ----
  316. .. _class_TileMap_method_is_cell_transposed:
  317. - :ref:`bool<class_bool>` **is_cell_transposed** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  318. Returns ``true`` if the given cell is transposed, i.e. the x and y axes are swapped.
  319. ----
  320. .. _class_TileMap_method_is_cell_x_flipped:
  321. - :ref:`bool<class_bool>` **is_cell_x_flipped** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  322. Returns ``true`` if the given cell is flipped in the x axis.
  323. ----
  324. .. _class_TileMap_method_is_cell_y_flipped:
  325. - :ref:`bool<class_bool>` **is_cell_y_flipped** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  326. Returns ``true`` if the given cell is flipped in the y axis.
  327. ----
  328. .. _class_TileMap_method_map_to_world:
  329. - :ref:`Vector2<class_Vector2>` **map_to_world** **(** :ref:`Vector2<class_Vector2>` map_position, :ref:`bool<class_bool>` ignore_half_ofs=false **)** const
  330. Returns the global position corresponding to the given tilemap (grid-based) coordinates.
  331. Optionally, the tilemap's half offset can be ignored.
  332. ----
  333. .. _class_TileMap_method_set_cell:
  334. - 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 ) **)**
  335. Sets the tile index for the cell given by a Vector2.
  336. An index of ``-1`` clears the cell.
  337. Optionally, the tile can also be flipped, transposed, or given autotile coordinates.
  338. Note that data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
  339. If you need these to be immediately updated, you can call :ref:`update_dirty_quadrants<class_TileMap_method_update_dirty_quadrants>`.
  340. ----
  341. .. _class_TileMap_method_set_cellv:
  342. - 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 **)**
  343. Sets the tile index for the given cell.
  344. An index of ``-1`` clears the cell.
  345. Optionally, the tile can also be flipped or transposed.
  346. Note that data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
  347. If you need these to be immediately updated, you can call :ref:`update_dirty_quadrants<class_TileMap_method_update_dirty_quadrants>`.
  348. ----
  349. .. _class_TileMap_method_set_collision_layer_bit:
  350. - void **set_collision_layer_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  351. Sets the given collision layer bit.
  352. ----
  353. .. _class_TileMap_method_set_collision_mask_bit:
  354. - void **set_collision_mask_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  355. Sets the given collision mask bit.
  356. ----
  357. .. _class_TileMap_method_update_bitmask_area:
  358. - void **update_bitmask_area** **(** :ref:`Vector2<class_Vector2>` position **)**
  359. Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based x and y coordinates.
  360. ----
  361. .. _class_TileMap_method_update_bitmask_region:
  362. - void **update_bitmask_region** **(** :ref:`Vector2<class_Vector2>` start=Vector2( 0, 0 ), :ref:`Vector2<class_Vector2>` end=Vector2( 0, 0 ) **)**
  363. Applies autotiling rules to the cells in the given region (specified by grid-based x and y coordinates).
  364. Calling with invalid (or missing) parameters applies autotiling rules for the entire tilemap.
  365. ----
  366. .. _class_TileMap_method_update_dirty_quadrants:
  367. - void **update_dirty_quadrants** **(** **)**
  368. Updates the tile map's quadrants, allowing things such as navigation and collision shapes to be immediately used if modified.
  369. ----
  370. .. _class_TileMap_method_world_to_map:
  371. - :ref:`Vector2<class_Vector2>` **world_to_map** **(** :ref:`Vector2<class_Vector2>` world_position **)** const
  372. Returns the tilemap (grid-based) coordinates corresponding to the given local position.