class_tilesetsource.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/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. .. rst-class:: classref-reftable-group
  20. Methods
  21. -------
  22. .. table::
  23. :widths: auto
  24. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :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| |
  26. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`get_alternative_tiles_count<class_TileSetSource_method_get_alternative_tiles_count>` **(** :ref:`Vector2i<class_Vector2i>` atlas_coords **)** |const| |
  28. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_tile_id<class_TileSetSource_method_get_tile_id>` **(** :ref:`int<class_int>` index **)** |const| |
  30. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`get_tiles_count<class_TileSetSource_method_get_tiles_count>` **(** **)** |const| |
  32. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :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| |
  34. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`has_tile<class_TileSetSource_method_has_tile>` **(** :ref:`Vector2i<class_Vector2i>` atlas_coords **)** |const| |
  36. +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. .. rst-class:: classref-section-separator
  38. ----
  39. .. rst-class:: classref-descriptions-group
  40. Method Descriptions
  41. -------------------
  42. .. _class_TileSetSource_method_get_alternative_tile_id:
  43. .. rst-class:: classref-method
  44. :ref:`int<class_int>` **get_alternative_tile_id** **(** :ref:`Vector2i<class_Vector2i>` atlas_coords, :ref:`int<class_int>` index **)** |const|
  45. Returns the alternative ID for the tile with coordinates ID ``atlas_coords`` at index ``index``.
  46. .. rst-class:: classref-item-separator
  47. ----
  48. .. _class_TileSetSource_method_get_alternative_tiles_count:
  49. .. rst-class:: classref-method
  50. :ref:`int<class_int>` **get_alternative_tiles_count** **(** :ref:`Vector2i<class_Vector2i>` atlas_coords **)** |const|
  51. Returns the number of alternatives tiles for the coordinates ID ``atlas_coords``.
  52. 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.
  53. Returns -1 if there is not tile at the given coords.
  54. .. rst-class:: classref-item-separator
  55. ----
  56. .. _class_TileSetSource_method_get_tile_id:
  57. .. rst-class:: classref-method
  58. :ref:`Vector2i<class_Vector2i>` **get_tile_id** **(** :ref:`int<class_int>` index **)** |const|
  59. Returns the tile coordinates ID of the tile with index ``index``.
  60. .. rst-class:: classref-item-separator
  61. ----
  62. .. _class_TileSetSource_method_get_tiles_count:
  63. .. rst-class:: classref-method
  64. :ref:`int<class_int>` **get_tiles_count** **(** **)** |const|
  65. Returns how many tiles this atlas source defines (not including alternative tiles).
  66. .. rst-class:: classref-item-separator
  67. ----
  68. .. _class_TileSetSource_method_has_alternative_tile:
  69. .. rst-class:: classref-method
  70. :ref:`bool<class_bool>` **has_alternative_tile** **(** :ref:`Vector2i<class_Vector2i>` atlas_coords, :ref:`int<class_int>` alternative_tile **)** |const|
  71. Returns if the base tile at coordinates ``atlas_coords`` has an alternative with ID ``alternative_tile``.
  72. .. rst-class:: classref-item-separator
  73. ----
  74. .. _class_TileSetSource_method_has_tile:
  75. .. rst-class:: classref-method
  76. :ref:`bool<class_bool>` **has_tile** **(** :ref:`Vector2i<class_Vector2i>` atlas_coords **)** |const|
  77. Returns if this atlas has a tile with coordinates ID ``atlas_coords``.
  78. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  79. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  80. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  81. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  82. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  83. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`