NavigationPolygon.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="NavigationPolygon" inherits="Resource" version="3.4">
  3. <brief_description>
  4. A node that has methods to draw outlines or use indices of vertices to create navigation polygons.
  5. </brief_description>
  6. <description>
  7. There are two ways to create polygons. Either by using the [method add_outline] method, or using the [method add_polygon] method.
  8. Using [method add_outline]:
  9. [codeblock]
  10. var polygon = NavigationPolygon.new()
  11. var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
  12. polygon.add_outline(outline)
  13. polygon.make_polygons_from_outlines()
  14. $NavigationPolygonInstance.navpoly = polygon
  15. [/codeblock]
  16. Using [method add_polygon] and indices of the vertices array.
  17. [codeblock]
  18. var polygon = NavigationPolygon.new()
  19. var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
  20. polygon.set_vertices(vertices)
  21. var indices = PoolIntArray(0, 3, 1)
  22. polygon.add_polygon(indices)
  23. $NavigationPolygonInstance.navpoly = polygon
  24. [/codeblock]
  25. </description>
  26. <tutorials>
  27. <link title="2D Navigation Demo">https://godotengine.org/asset-library/asset/117</link>
  28. </tutorials>
  29. <methods>
  30. <method name="add_outline">
  31. <return type="void">
  32. </return>
  33. <argument index="0" name="outline" type="PoolVector2Array">
  34. </argument>
  35. <description>
  36. Appends a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
  37. </description>
  38. </method>
  39. <method name="add_outline_at_index">
  40. <return type="void">
  41. </return>
  42. <argument index="0" name="outline" type="PoolVector2Array">
  43. </argument>
  44. <argument index="1" name="index" type="int">
  45. </argument>
  46. <description>
  47. Adds a [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 [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
  48. </description>
  49. </method>
  50. <method name="add_polygon">
  51. <return type="void">
  52. </return>
  53. <argument index="0" name="polygon" type="PoolIntArray">
  54. </argument>
  55. <description>
  56. Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
  57. </description>
  58. </method>
  59. <method name="clear_outlines">
  60. <return type="void">
  61. </return>
  62. <description>
  63. Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
  64. </description>
  65. </method>
  66. <method name="clear_polygons">
  67. <return type="void">
  68. </return>
  69. <description>
  70. Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
  71. </description>
  72. </method>
  73. <method name="get_outline" qualifiers="const">
  74. <return type="PoolVector2Array">
  75. </return>
  76. <argument index="0" name="idx" type="int">
  77. </argument>
  78. <description>
  79. Returns a [PoolVector2Array] containing the vertices of an outline that was created in the editor or by script.
  80. </description>
  81. </method>
  82. <method name="get_outline_count" qualifiers="const">
  83. <return type="int">
  84. </return>
  85. <description>
  86. Returns the number of outlines that were created in the editor or by script.
  87. </description>
  88. </method>
  89. <method name="get_polygon">
  90. <return type="PoolIntArray">
  91. </return>
  92. <argument index="0" name="idx" type="int">
  93. </argument>
  94. <description>
  95. Returns a [PoolIntArray] containing the indices of the vertices of a created polygon.
  96. </description>
  97. </method>
  98. <method name="get_polygon_count" qualifiers="const">
  99. <return type="int">
  100. </return>
  101. <description>
  102. Returns the count of all polygons.
  103. </description>
  104. </method>
  105. <method name="get_vertices" qualifiers="const">
  106. <return type="PoolVector2Array">
  107. </return>
  108. <description>
  109. Returns a [PoolVector2Array] containing all the vertices being used to create the polygons.
  110. </description>
  111. </method>
  112. <method name="make_polygons_from_outlines">
  113. <return type="void">
  114. </return>
  115. <description>
  116. Creates polygons from the outlines added in the editor or by script.
  117. </description>
  118. </method>
  119. <method name="remove_outline">
  120. <return type="void">
  121. </return>
  122. <argument index="0" name="idx" type="int">
  123. </argument>
  124. <description>
  125. Removes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
  126. </description>
  127. </method>
  128. <method name="set_outline">
  129. <return type="void">
  130. </return>
  131. <argument index="0" name="idx" type="int">
  132. </argument>
  133. <argument index="1" name="outline" type="PoolVector2Array">
  134. </argument>
  135. <description>
  136. Changes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
  137. </description>
  138. </method>
  139. <method name="set_vertices">
  140. <return type="void">
  141. </return>
  142. <argument index="0" name="vertices" type="PoolVector2Array">
  143. </argument>
  144. <description>
  145. Sets the vertices that can be then indexed to create polygons with the [method add_polygon] method.
  146. </description>
  147. </method>
  148. </methods>
  149. <constants>
  150. </constants>
  151. </class>