2
0

TileSetAtlasSource.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="TileSetAtlasSource" inherits="TileSetSource" version="4.0">
  3. <brief_description>
  4. Exposes a 2D atlas texture as a set of tiles for a [TileSet] resource.
  5. </brief_description>
  6. <description>
  7. An atlas is a grid of tiles laid out on a texture. Each tile in the grid must be exposed using [method create_tile]. Those tiles are then indexed using their coordinates in the grid.
  8. Each tile can also have a size in the grid coordinates, making it more or less cells in the atlas.
  9. Alternatives version of a tile can be created using [method create_alternative_tile], which are then indexed using an alternative ID. The main tile (the one in the grid), is accessed with an alternative ID equal to 0.
  10. Each tile alternate has a set of properties that is defined by the source's [TileSet] layers. Those properties are stored in a TileData object that can be accessed and modified using [method get_tile_data].
  11. As TileData properties are stored directly in the TileSetAtlasSource resource, their properties might also be set using [code]TileSetAtlasSource.set("&lt;coords_x&gt;:&lt;coords_y&gt;/&lt;alternative_id&gt;/&lt;tile_data_property&gt;")[/code].
  12. </description>
  13. <tutorials>
  14. </tutorials>
  15. <methods>
  16. <method name="create_alternative_tile">
  17. <return type="int" />
  18. <argument index="0" name="atlas_coords" type="Vector2i" />
  19. <argument index="1" name="alternative_id_override" type="int" default="-1" />
  20. <description>
  21. Creates an alternative tile for the tile at coords [code]atlas_coords[/code]. If [code]alternative_id_override[/code] is -1, give it an automatically generated unique ID, or assigns it the given ID otherwise.
  22. Returns the new alternative identifier, or -1 if the alternative could not be created with a provided [code]alternative_id_override[/code].
  23. </description>
  24. </method>
  25. <method name="create_tile">
  26. <return type="void" />
  27. <argument index="0" name="atlas_coords" type="Vector2i" />
  28. <argument index="1" name="size" type="Vector2i" default="Vector2i(1, 1)" />
  29. <description>
  30. Creates a new tile at coords [code]atlas_coords[/code] with size [code]size[/code].
  31. </description>
  32. </method>
  33. <method name="get_atlas_grid_size" qualifiers="const">
  34. <return type="Vector2i" />
  35. <description>
  36. Returns the atlas grid size, which depends on how many tiles can fit in the texture. It thus depends on the Texture's size, the atlas [code]margins[/code] the tiles' [code]texture_region_size[/code].
  37. </description>
  38. </method>
  39. <method name="get_next_alternative_tile_id" qualifiers="const">
  40. <return type="int" />
  41. <argument index="0" name="atlas_coords" type="Vector2i" />
  42. <description>
  43. Returns the alternative ID a following call to [method create_alternative_tile] would return.
  44. </description>
  45. </method>
  46. <method name="get_tile_animation_columns" qualifiers="const">
  47. <return type="int" />
  48. <argument index="0" name="atlas_coords" type="Vector2i" />
  49. <description>
  50. Returns how many columns the tile at [code]atlas_coords[/code] has in its animation layout.
  51. </description>
  52. </method>
  53. <method name="get_tile_animation_frame_duration" qualifiers="const">
  54. <return type="float" />
  55. <argument index="0" name="atlas_coords" type="Vector2i" />
  56. <argument index="1" name="frame_index" type="int" />
  57. <description>
  58. Returns the animation frame duration of frame [code]frame_index[/code] for the tile at coordinates [code]atlas_coords[/code].
  59. </description>
  60. </method>
  61. <method name="get_tile_animation_frames_count" qualifiers="const">
  62. <return type="int" />
  63. <argument index="0" name="atlas_coords" type="Vector2i" />
  64. <description>
  65. Returns how many animation frames has the tile at coordinates [code]atlas_coords[/code].
  66. </description>
  67. </method>
  68. <method name="get_tile_animation_separation" qualifiers="const">
  69. <return type="Vector2i" />
  70. <argument index="0" name="atlas_coords" type="Vector2i" />
  71. <description>
  72. Returns the separation (as in the atlas grid) between each frame of an animated tile at coordinates [code]atlas_coords[/code].
  73. </description>
  74. </method>
  75. <method name="get_tile_animation_speed" qualifiers="const">
  76. <return type="float" />
  77. <argument index="0" name="atlas_coords" type="Vector2i" />
  78. <description>
  79. Returns the animation speed of the tile at coordinates [code]atlas_coords[/code].
  80. </description>
  81. </method>
  82. <method name="get_tile_animation_total_duration" qualifiers="const">
  83. <return type="float" />
  84. <argument index="0" name="atlas_coords" type="Vector2i" />
  85. <description>
  86. Returns the sum of the sum of the frame durations of the tile at coordinates [code]atlas_coords[/code]. This value needs to be divided by the animation speed to get the actual animation loop duration.
  87. </description>
  88. </method>
  89. <method name="get_tile_at_coords" qualifiers="const">
  90. <return type="Vector2i" />
  91. <argument index="0" name="atlas_coords" type="Vector2i" />
  92. <description>
  93. If there is a tile covering the [code]atlas_coords[/code] coordinates, returns the top-left coordinates of the tile (thus its coordinate ID). Returns [code]Vector2i(-1, -1)[/code] otherwise.
  94. </description>
  95. </method>
  96. <method name="get_tile_data" qualifiers="const">
  97. <return type="Object" />
  98. <argument index="0" name="atlas_coords" type="Vector2i" />
  99. <argument index="1" name="alternative_tile" type="int" />
  100. <description>
  101. Returns the [TileData] object for the given atlas coordinates and alternative ID.
  102. </description>
  103. </method>
  104. <method name="get_tile_size_in_atlas" qualifiers="const">
  105. <return type="Vector2i" />
  106. <argument index="0" name="atlas_coords" type="Vector2i" />
  107. <description>
  108. Returns the size of the tile (in the grid coordinates system) at coordinates [code]atlas_coords[/code].
  109. </description>
  110. </method>
  111. <method name="get_tile_texture_region" qualifiers="const">
  112. <return type="Rect2i" />
  113. <argument index="0" name="atlas_coords" type="Vector2i" />
  114. <argument index="1" name="frame" type="int" default="0" />
  115. <description>
  116. Returns a tile's texture region in the atlas texture. For animated tiles, a [code]frame[/code] argument might be provided for the different frames of the animation.
  117. </description>
  118. </method>
  119. <method name="get_tiles_to_be_removed_on_change">
  120. <return type="PackedVector2Array" />
  121. <argument index="0" name="texture" type="Texture2D" />
  122. <argument index="1" name="margins" type="Vector2i" />
  123. <argument index="2" name="separation" type="Vector2i" />
  124. <argument index="3" name="texture_region_size" type="Vector2i" />
  125. <description>
  126. Returns an array of tiles coordinates ID that will be automatically removed when modifying one or several of those properties: [code]texture[/code], [code]margins[/code], [code]separation[/code] or [code]texture_region_size[/code]. This can be used to undo changes that would have caused tiles data loss.
  127. </description>
  128. </method>
  129. <method name="has_room_for_tile" qualifiers="const">
  130. <return type="bool" />
  131. <argument index="0" name="atlas_coords" type="Vector2i" />
  132. <argument index="1" name="size" type="Vector2i" />
  133. <argument index="2" name="animation_columns" type="int" />
  134. <argument index="3" name="animation_separation" type="Vector2i" />
  135. <argument index="4" name="frames_count" type="int" />
  136. <argument index="5" name="ignored_tile" type="Vector2i" default="Vector2i(-1, -1)" />
  137. <description>
  138. Returns whether there is enough room in an atlas to create/modify a tile with the given properties. If [code]ignored_tile[/code] is provided, act as is the given tile was not present in the atlas. This may be used when you want to modify a tile's properties.
  139. </description>
  140. </method>
  141. <method name="move_tile_in_atlas">
  142. <return type="void" />
  143. <argument index="0" name="atlas_coords" type="Vector2i" />
  144. <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" />
  145. <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)" />
  146. <description>
  147. Move the tile and its alternatives at the [code]atlas_coords[/code] coordinates to the [code]new_atlas_coords[/code] coordinates with the [code]new_size[/code] size. This functions will fail if a tile is already present in the given area.
  148. If [code]new_atlas_coords[/code] is [code]Vector2i(-1, -1)[/code], keeps the tile's coordinates. If [code]new_size[/code] is [code]Vector2i(-1, -1)[/code], keeps the tile's size.
  149. To avoid an error, first check if a move is possible using [method has_room_for_tile].
  150. </description>
  151. </method>
  152. <method name="remove_alternative_tile">
  153. <return type="void" />
  154. <argument index="0" name="atlas_coords" type="Vector2i" />
  155. <argument index="1" name="alternative_tile" type="int" />
  156. <description>
  157. Remove a tile's alternative with alternative ID [code]alternative_tile[/code].
  158. Calling this function with [code]alternative_tile[/code] equals to 0 will fail, as the base tile alternative cannot be removed.
  159. </description>
  160. </method>
  161. <method name="remove_tile">
  162. <return type="void" />
  163. <argument index="0" name="atlas_coords" type="Vector2i" />
  164. <description>
  165. Remove a tile and its alternative at coordinates [code]atlas_coords[/code].
  166. </description>
  167. </method>
  168. <method name="set_alternative_tile_id">
  169. <return type="void" />
  170. <argument index="0" name="atlas_coords" type="Vector2i" />
  171. <argument index="1" name="alternative_tile" type="int" />
  172. <argument index="2" name="new_id" type="int" />
  173. <description>
  174. Change a tile's alternative ID from [code]alternative_tile[/code] to [code]new_id[/code].
  175. Calling this function with [code]alternative_id[/code] equals to 0 will fail, as the base tile alternative cannot be moved.
  176. </description>
  177. </method>
  178. <method name="set_tile_animation_columns">
  179. <return type="void" />
  180. <argument index="0" name="atlas_coords" type="Vector2i" />
  181. <argument index="1" name="frame_columns" type="int" />
  182. <description>
  183. Sets the number of columns in the animation layout of the tile at coordinates [code]atlas_coords[/code]. If set to 0, then the different frames of the animation are laid out as a single horizontal line in the atlas.
  184. </description>
  185. </method>
  186. <method name="set_tile_animation_frame_duration">
  187. <return type="void" />
  188. <argument index="0" name="atlas_coords" type="Vector2i" />
  189. <argument index="1" name="frame_index" type="int" />
  190. <argument index="2" name="duration" type="float" />
  191. <description>
  192. Sets the animation frame duration of frame [code]frame_index[/code] for the tile at coordinates [code]atlas_coords[/code].
  193. </description>
  194. </method>
  195. <method name="set_tile_animation_frames_count">
  196. <return type="void" />
  197. <argument index="0" name="atlas_coords" type="Vector2i" />
  198. <argument index="1" name="frames_count" type="int" />
  199. <description>
  200. Sets how many animation frames the tile at coordinates [code]atlas_coords[/code] has.
  201. </description>
  202. </method>
  203. <method name="set_tile_animation_separation">
  204. <return type="void" />
  205. <argument index="0" name="atlas_coords" type="Vector2i" />
  206. <argument index="1" name="separation" type="Vector2i" />
  207. <description>
  208. Sets the margin (in grid tiles) between each tile in the animation layout of the tile at coordinates [code]atlas_coords[/code] has.
  209. </description>
  210. </method>
  211. <method name="set_tile_animation_speed">
  212. <return type="void" />
  213. <argument index="0" name="atlas_coords" type="Vector2i" />
  214. <argument index="1" name="speed" type="float" />
  215. <description>
  216. Sets the animation speed of the tile at coordinates [code]atlas_coords[/code] has.
  217. </description>
  218. </method>
  219. </methods>
  220. <members>
  221. <member name="margins" type="Vector2i" setter="set_margins" getter="get_margins" default="Vector2i(0, 0)">
  222. Margins, in pixels, to offset the origin of the grid in the texture.
  223. </member>
  224. <member name="separation" type="Vector2i" setter="set_separation" getter="get_separation" default="Vector2i(0, 0)">
  225. Separation, in pixels, between each tile texture region of the grid.
  226. </member>
  227. <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture">
  228. The atlas texture.
  229. </member>
  230. <member name="texture_region_size" type="Vector2i" setter="set_texture_region_size" getter="get_texture_region_size" default="Vector2i(16, 16)">
  231. The base tile size in the texture (in pixel). This size must be bigger than the TileSet's [code]tile_size[/code] value.
  232. </member>
  233. </members>
  234. </class>