class_tilesetsource.rst 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/TileSetSource.xml.
  6. .. _class_TileSetSource:
  7. TileSetSource
  8. =============
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`, :ref:`TileSetScenesCollectionSource<class_TileSetScenesCollectionSource>`
  11. Exposes a set of tiles for a :ref:`TileSet<class_TileSet>` resource.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Exposes a set of tiles for a :ref:`TileSet<class_TileSet>` resource.
  16. Tiles in a source are indexed with two IDs, coordinates ID (of type Vector2i) and an alternative ID (of type int), named according to their use in the :ref:`TileSetAtlasSource<class_TileSetAtlasSource>` class.
  17. Depending on the TileSet source type, those IDs might have restrictions on their values, this is why the base **TileSetSource** class only exposes getters for them.
  18. You can iterate over all tiles exposed by a TileSetSource by first iterating over coordinates IDs using :ref:`get_tiles_count<class_TileSetSource_method_get_tiles_count>` and :ref:`get_tile_id<class_TileSetSource_method_get_tile_id>`, then over alternative IDs using :ref:`get_alternative_tiles_count<class_TileSetSource_method_get_alternative_tiles_count>` and :ref:`get_alternative_tile_id<class_TileSetSource_method_get_alternative_tile_id>`.
  19. \ **Warning:** **TileSetSource** can only be added to one TileSet at the same time. Calling :ref:`TileSet.add_source<class_TileSet_method_add_source>` on a second :ref:`TileSet<class_TileSet>` will remove the source from the first one.
  20. .. rst-class:: classref-reftable-group
  21. Methods
  22. -------
  23. .. table::
  24. :widths: auto
  25. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`get_alternative_tile_id<class_TileSetSource_method_get_alternative_tile_id>` **(** :ref:`Vector2i<class_Vector2i>` atlas_coords, :ref:`int<class_int>` index **)** |const| |
  27. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`int<class_int>` | :ref:`get_alternative_tiles_count<class_TileSetSource_method_get_alternative_tiles_count>` **(** :ref:`Vector2i<class_Vector2i>` atlas_coords **)** |const| |
  29. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_tile_id<class_TileSetSource_method_get_tile_id>` **(** :ref:`int<class_int>` index **)** |const| |
  31. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`int<class_int>` | :ref:`get_tiles_count<class_TileSetSource_method_get_tiles_count>` **(** **)** |const| |
  33. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`bool<class_bool>` | :ref:`has_alternative_tile<class_TileSetSource_method_has_alternative_tile>` **(** :ref:`Vector2i<class_Vector2i>` atlas_coords, :ref:`int<class_int>` alternative_tile **)** |const| |
  35. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`has_tile<class_TileSetSource_method_has_tile>` **(** :ref:`Vector2i<class_Vector2i>` atlas_coords **)** |const| |
  37. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. .. rst-class:: classref-section-separator
  39. ----
  40. .. rst-class:: classref-descriptions-group
  41. Method Descriptions
  42. -------------------
  43. .. _class_TileSetSource_method_get_alternative_tile_id:
  44. .. rst-class:: classref-method
  45. :ref:`int<class_int>` **get_alternative_tile_id** **(** :ref:`Vector2i<class_Vector2i>` atlas_coords, :ref:`int<class_int>` index **)** |const|
  46. Returns the alternative ID for the tile with coordinates ID ``atlas_coords`` at index ``index``.
  47. .. rst-class:: classref-item-separator
  48. ----
  49. .. _class_TileSetSource_method_get_alternative_tiles_count:
  50. .. rst-class:: classref-method
  51. :ref:`int<class_int>` **get_alternative_tiles_count** **(** :ref:`Vector2i<class_Vector2i>` atlas_coords **)** |const|
  52. Returns the number of alternatives tiles for the coordinates ID ``atlas_coords``.
  53. For :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`, this always return at least 1, as the base tile with ID 0 is always part of the alternatives list.
  54. Returns -1 if there is not tile at the given coords.
  55. .. rst-class:: classref-item-separator
  56. ----
  57. .. _class_TileSetSource_method_get_tile_id:
  58. .. rst-class:: classref-method
  59. :ref:`Vector2i<class_Vector2i>` **get_tile_id** **(** :ref:`int<class_int>` index **)** |const|
  60. Returns the tile coordinates ID of the tile with index ``index``.
  61. .. rst-class:: classref-item-separator
  62. ----
  63. .. _class_TileSetSource_method_get_tiles_count:
  64. .. rst-class:: classref-method
  65. :ref:`int<class_int>` **get_tiles_count** **(** **)** |const|
  66. Returns how many tiles this atlas source defines (not including alternative tiles).
  67. .. rst-class:: classref-item-separator
  68. ----
  69. .. _class_TileSetSource_method_has_alternative_tile:
  70. .. rst-class:: classref-method
  71. :ref:`bool<class_bool>` **has_alternative_tile** **(** :ref:`Vector2i<class_Vector2i>` atlas_coords, :ref:`int<class_int>` alternative_tile **)** |const|
  72. Returns if the base tile at coordinates ``atlas_coords`` has an alternative with ID ``alternative_tile``.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_TileSetSource_method_has_tile:
  76. .. rst-class:: classref-method
  77. :ref:`bool<class_bool>` **has_tile** **(** :ref:`Vector2i<class_Vector2i>` atlas_coords **)** |const|
  78. Returns if this atlas has a tile with coordinates ID ``atlas_coords``.
  79. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  80. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  81. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  82. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  83. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  84. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  85. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`