class_navigationpolygon.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 NavigationPolygon.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_NavigationPolygon:
  6. NavigationPolygon
  7. =================
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. A node that has methods to draw outlines or use indices of vertices to create navigation polygons.
  13. Methods
  14. -------
  15. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`add_outline<class_NavigationPolygon_method_add_outline>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` outline **)** |
  17. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`add_outline_at_index<class_NavigationPolygon_method_add_outline_at_index>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` outline, :ref:`int<class_int>` index **)** |
  19. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`add_polygon<class_NavigationPolygon_method_add_polygon>` **(** :ref:`PoolIntArray<class_PoolIntArray>` polygon **)** |
  21. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`clear_outlines<class_NavigationPolygon_method_clear_outlines>` **(** **)** |
  23. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`clear_polygons<class_NavigationPolygon_method_clear_polygons>` **(** **)** |
  25. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`get_outline<class_NavigationPolygon_method_get_outline>` **(** :ref:`int<class_int>` idx **)** const |
  27. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`int<class_int>` | :ref:`get_outline_count<class_NavigationPolygon_method_get_outline_count>` **(** **)** const |
  29. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`PoolIntArray<class_PoolIntArray>` | :ref:`get_polygon<class_NavigationPolygon_method_get_polygon>` **(** :ref:`int<class_int>` idx **)** |
  31. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`int<class_int>` | :ref:`get_polygon_count<class_NavigationPolygon_method_get_polygon_count>` **(** **)** const |
  33. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`get_vertices<class_NavigationPolygon_method_get_vertices>` **(** **)** const |
  35. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`make_polygons_from_outlines<class_NavigationPolygon_method_make_polygons_from_outlines>` **(** **)** |
  37. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`remove_outline<class_NavigationPolygon_method_remove_outline>` **(** :ref:`int<class_int>` idx **)** |
  39. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_outline<class_NavigationPolygon_method_set_outline>` **(** :ref:`int<class_int>` idx, :ref:`PoolVector2Array<class_PoolVector2Array>` outline **)** |
  41. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`set_vertices<class_NavigationPolygon_method_set_vertices>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` vertices **)** |
  43. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. Description
  45. -----------
  46. There are two ways to create polygons. Either by using the :ref:`add_outline<class_NavigationPolygon_method_add_outline>` method, or using the :ref:`add_polygon<class_NavigationPolygon_method_add_polygon>` method.
  47. Using :ref:`add_outline<class_NavigationPolygon_method_add_outline>`:
  48. ::
  49. var polygon = NavigationPolygon.new()
  50. var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
  51. polygon.add_outline(outline)
  52. polygon.make_polygons_from_outlines()
  53. $NavigationPolygonInstance.navpoly = polygon
  54. Using :ref:`add_polygon<class_NavigationPolygon_method_add_polygon>` and indices of the vertices array.
  55. ::
  56. var polygon = NavigationPolygon.new()
  57. var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
  58. polygon.set_vertices(vertices)
  59. var indices = PoolIntArray(0, 3, 1)
  60. polygon.add_polygon(indices)
  61. $NavigationPolygonInstance.navpoly = polygon
  62. Method Descriptions
  63. -------------------
  64. .. _class_NavigationPolygon_method_add_outline:
  65. - void **add_outline** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` outline **)**
  66. Appends a :ref:`PoolVector2Array<class_PoolVector2Array>` that contains the vertices of an outline to the internal array that contains all the outlines. You have to call :ref:`make_polygons_from_outlines<class_NavigationPolygon_method_make_polygons_from_outlines>` in order for this array to be converted to polygons that the engine will use.
  67. .. _class_NavigationPolygon_method_add_outline_at_index:
  68. - void **add_outline_at_index** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` outline, :ref:`int<class_int>` index **)**
  69. Adds a :ref:`PoolVector2Array<class_PoolVector2Array>` that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call :ref:`make_polygons_from_outlines<class_NavigationPolygon_method_make_polygons_from_outlines>` in order for this array to be converted to polygons that the engine will use.
  70. .. _class_NavigationPolygon_method_add_polygon:
  71. - void **add_polygon** **(** :ref:`PoolIntArray<class_PoolIntArray>` polygon **)**
  72. Adds a polygon using the indices of the vertices you get when calling :ref:`get_vertices<class_NavigationPolygon_method_get_vertices>`.
  73. .. _class_NavigationPolygon_method_clear_outlines:
  74. - void **clear_outlines** **(** **)**
  75. Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
  76. .. _class_NavigationPolygon_method_clear_polygons:
  77. - void **clear_polygons** **(** **)**
  78. Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
  79. .. _class_NavigationPolygon_method_get_outline:
  80. - :ref:`PoolVector2Array<class_PoolVector2Array>` **get_outline** **(** :ref:`int<class_int>` idx **)** const
  81. Returns a :ref:`PoolVector2Array<class_PoolVector2Array>` containing the vertices of an outline that was created in the editor or by script.
  82. .. _class_NavigationPolygon_method_get_outline_count:
  83. - :ref:`int<class_int>` **get_outline_count** **(** **)** const
  84. Returns the number of outlines that were created in the editor or by script.
  85. .. _class_NavigationPolygon_method_get_polygon:
  86. - :ref:`PoolIntArray<class_PoolIntArray>` **get_polygon** **(** :ref:`int<class_int>` idx **)**
  87. Returns a :ref:`PoolIntArray<class_PoolIntArray>` containing the indices of the vertices of a created polygon.
  88. .. _class_NavigationPolygon_method_get_polygon_count:
  89. - :ref:`int<class_int>` **get_polygon_count** **(** **)** const
  90. Returns the count of all polygons.
  91. .. _class_NavigationPolygon_method_get_vertices:
  92. - :ref:`PoolVector2Array<class_PoolVector2Array>` **get_vertices** **(** **)** const
  93. Returns a :ref:`PoolVector2Array<class_PoolVector2Array>` containing all the vertices being used to create the polygons.
  94. .. _class_NavigationPolygon_method_make_polygons_from_outlines:
  95. - void **make_polygons_from_outlines** **(** **)**
  96. Creates polygons from the outlines added in the editor or by script.
  97. .. _class_NavigationPolygon_method_remove_outline:
  98. - void **remove_outline** **(** :ref:`int<class_int>` idx **)**
  99. Removes an outline created in the editor or by script. You have to call :ref:`make_polygons_from_outlines<class_NavigationPolygon_method_make_polygons_from_outlines>` for the polygons to update.
  100. .. _class_NavigationPolygon_method_set_outline:
  101. - void **set_outline** **(** :ref:`int<class_int>` idx, :ref:`PoolVector2Array<class_PoolVector2Array>` outline **)**
  102. Changes an outline created in the editor or by script. You have to call :ref:`make_polygons_from_outlines<class_NavigationPolygon_method_make_polygons_from_outlines>` for the polygons to update.
  103. .. _class_NavigationPolygon_method_set_vertices:
  104. - void **set_vertices** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` vertices **)**
  105. Sets the vertices that can be then indexed to create polygons with the :ref:`add_polygon<class_NavigationPolygon_method_add_polygon>` method.