NavigationPolygon.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="NavigationPolygon" inherits="Resource" category="Core" version="3.1.2">
  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. </tutorials>
  28. <methods>
  29. <method name="add_outline">
  30. <return type="void">
  31. </return>
  32. <argument index="0" name="outline" type="PoolVector2Array">
  33. </argument>
  34. <description>
  35. 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.
  36. </description>
  37. </method>
  38. <method name="add_outline_at_index">
  39. <return type="void">
  40. </return>
  41. <argument index="0" name="outline" type="PoolVector2Array">
  42. </argument>
  43. <argument index="1" name="index" type="int">
  44. </argument>
  45. <description>
  46. 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.
  47. </description>
  48. </method>
  49. <method name="add_polygon">
  50. <return type="void">
  51. </return>
  52. <argument index="0" name="polygon" type="PoolIntArray">
  53. </argument>
  54. <description>
  55. Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
  56. </description>
  57. </method>
  58. <method name="clear_outlines">
  59. <return type="void">
  60. </return>
  61. <description>
  62. Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
  63. </description>
  64. </method>
  65. <method name="clear_polygons">
  66. <return type="void">
  67. </return>
  68. <description>
  69. Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
  70. </description>
  71. </method>
  72. <method name="get_outline" qualifiers="const">
  73. <return type="PoolVector2Array">
  74. </return>
  75. <argument index="0" name="idx" type="int">
  76. </argument>
  77. <description>
  78. Returns a [PoolVector2Array] containing the vertices of an outline that was created in the editor or by script.
  79. </description>
  80. </method>
  81. <method name="get_outline_count" qualifiers="const">
  82. <return type="int">
  83. </return>
  84. <description>
  85. Returns the number of outlines that were created in the editor or by script.
  86. </description>
  87. </method>
  88. <method name="get_polygon">
  89. <return type="PoolIntArray">
  90. </return>
  91. <argument index="0" name="idx" type="int">
  92. </argument>
  93. <description>
  94. Returns a [PoolIntArray] containing the indices of the vertices of a created polygon.
  95. </description>
  96. </method>
  97. <method name="get_polygon_count" qualifiers="const">
  98. <return type="int">
  99. </return>
  100. <description>
  101. Returns the count of all polygons.
  102. </description>
  103. </method>
  104. <method name="get_vertices" qualifiers="const">
  105. <return type="PoolVector2Array">
  106. </return>
  107. <description>
  108. Returns a [PoolVector2Array] containing all the vertices being used to create the polygons.
  109. </description>
  110. </method>
  111. <method name="make_polygons_from_outlines">
  112. <return type="void">
  113. </return>
  114. <description>
  115. Creates polygons from the outlines added in the editor or by script.
  116. </description>
  117. </method>
  118. <method name="remove_outline">
  119. <return type="void">
  120. </return>
  121. <argument index="0" name="idx" type="int">
  122. </argument>
  123. <description>
  124. Removes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
  125. </description>
  126. </method>
  127. <method name="set_outline">
  128. <return type="void">
  129. </return>
  130. <argument index="0" name="idx" type="int">
  131. </argument>
  132. <argument index="1" name="outline" type="PoolVector2Array">
  133. </argument>
  134. <description>
  135. Changes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
  136. </description>
  137. </method>
  138. <method name="set_vertices">
  139. <return type="void">
  140. </return>
  141. <argument index="0" name="vertices" type="PoolVector2Array">
  142. </argument>
  143. <description>
  144. Sets the vertices that can be then indexed to create polygons with the [method add_polygon] method.
  145. </description>
  146. </method>
  147. </methods>
  148. <constants>
  149. </constants>
  150. </class>