class_collisionpolygon2d.rst 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the CollisionPolygon2D.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_CollisionPolygon2D:
  5. CollisionPolygon2D
  6. ==================
  7. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Defines a 2D collision polygon.
  12. Member Functions
  13. ----------------
  14. +--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`get_build_mode<class_CollisionPolygon2D_get_build_mode>` **(** **)** const |
  16. +--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`PoolVector2Array<class_poolvector2array>` | :ref:`get_polygon<class_CollisionPolygon2D_get_polygon>` **(** **)** const |
  18. +--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`bool<class_bool>` | :ref:`is_disabled<class_CollisionPolygon2D_is_disabled>` **(** **)** const |
  20. +--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`bool<class_bool>` | :ref:`is_one_way_collision_enabled<class_CollisionPolygon2D_is_one_way_collision_enabled>` **(** **)** const |
  22. +--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`set_build_mode<class_CollisionPolygon2D_set_build_mode>` **(** :ref:`int<class_int>` build_mode **)** |
  24. +--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`set_disabled<class_CollisionPolygon2D_set_disabled>` **(** :ref:`bool<class_bool>` disabled **)** |
  26. +--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`set_one_way_collision<class_CollisionPolygon2D_set_one_way_collision>` **(** :ref:`bool<class_bool>` enabled **)** |
  28. +--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`set_polygon<class_CollisionPolygon2D_set_polygon>` **(** :ref:`PoolVector2Array<class_poolvector2array>` polygon **)** |
  30. +--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  31. Member Variables
  32. ----------------
  33. - :ref:`int<class_int>` **build_mode** - Collision build mode. Use one of the [code]BUILD_*[/code] constants. Default value: [code]BUILD_SOLIDS[/code].
  34. - :ref:`bool<class_bool>` **disabled** - If [code]true[/code] no collisions will be detected.
  35. - :ref:`bool<class_bool>` **one_way_collision** - If [code]true[/code] only edges that face up, relative to CollisionPolygon2D's rotation, will collide with other objects.
  36. - :ref:`PoolVector2Array<class_poolvector2array>` **polygon** - The polygon's list of vertices. The final point will be connected to the first.
  37. Numeric Constants
  38. -----------------
  39. - **BUILD_SOLIDS** = **0** --- Collisions will include the polygon and its contained area.
  40. - **BUILD_SEGMENTS** = **1** --- Collisions will only include the polygon edges.
  41. Description
  42. -----------
  43. Provides a 2D collision polygon to a :ref:`CollisionObject2D<class_collisionobject2d>` parent. Polygon can be drawn in the editor or specified by a list of vertices.
  44. Member Function Description
  45. ---------------------------
  46. .. _class_CollisionPolygon2D_get_build_mode:
  47. - :ref:`int<class_int>` **get_build_mode** **(** **)** const
  48. Return whether the polygon is a :ref:`ConvexPolygonShape2D<class_convexpolygonshape2d>` (``build_mode==0``), or a :ref:`ConcavePolygonShape2D<class_concavepolygonshape2d>` (``build_mode==1``).
  49. .. _class_CollisionPolygon2D_get_polygon:
  50. - :ref:`PoolVector2Array<class_poolvector2array>` **get_polygon** **(** **)** const
  51. Return the list of points that define the polygon.
  52. .. _class_CollisionPolygon2D_is_disabled:
  53. - :ref:`bool<class_bool>` **is_disabled** **(** **)** const
  54. .. _class_CollisionPolygon2D_is_one_way_collision_enabled:
  55. - :ref:`bool<class_bool>` **is_one_way_collision_enabled** **(** **)** const
  56. .. _class_CollisionPolygon2D_set_build_mode:
  57. - void **set_build_mode** **(** :ref:`int<class_int>` build_mode **)**
  58. Set whether the polygon is to be a :ref:`ConvexPolygonShape2D<class_convexpolygonshape2d>` (``build_mode==0``), or a :ref:`ConcavePolygonShape2D<class_concavepolygonshape2d>` (``build_mode==1``).
  59. .. _class_CollisionPolygon2D_set_disabled:
  60. - void **set_disabled** **(** :ref:`bool<class_bool>` disabled **)**
  61. .. _class_CollisionPolygon2D_set_one_way_collision:
  62. - void **set_one_way_collision** **(** :ref:`bool<class_bool>` enabled **)**
  63. .. _class_CollisionPolygon2D_set_polygon:
  64. - void **set_polygon** **(** :ref:`PoolVector2Array<class_poolvector2array>` polygon **)**
  65. Set the array of points forming the polygon.
  66. When editing the point list via the editor, depending on :ref:`get_build_mode<class_CollisionPolygon2D_get_build_mode>`, it has to be a list of points (for ``build_mode==0``), or a list of lines (for ``build_mode==1``). In the second case, the even elements of the array define the start point of the line, and the odd elements the end point.