class_collisionpolygon2d.rst 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_CollisionPolygon2D:
  4. CollisionPolygon2D
  5. ==================
  6. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Editor-only class for easy editing of collision polygons.
  11. Member Functions
  12. ----------------
  13. +------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`int<class_int>` | :ref:`get_build_mode<class_CollisionPolygon2D_get_build_mode>` **(** **)** const |
  15. +------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`int<class_int>` | :ref:`get_collision_object_first_shape<class_CollisionPolygon2D_get_collision_object_first_shape>` **(** **)** const |
  17. +------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`int<class_int>` | :ref:`get_collision_object_last_shape<class_CollisionPolygon2D_get_collision_object_last_shape>` **(** **)** const |
  19. +------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`Vector2Array<class_vector2array>` | :ref:`get_polygon<class_CollisionPolygon2D_get_polygon>` **(** **)** const |
  21. +------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`is_trigger<class_CollisionPolygon2D_is_trigger>` **(** **)** const |
  23. +------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`set_build_mode<class_CollisionPolygon2D_set_build_mode>` **(** :ref:`int<class_int>` build_mode **)** |
  25. +------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`set_polygon<class_CollisionPolygon2D_set_polygon>` **(** :ref:`Vector2Array<class_vector2array>` polygon **)** |
  27. +------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`set_trigger<class_CollisionPolygon2D_set_trigger>` **(** :ref:`bool<class_bool>` trigger **)** |
  29. +------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
  30. Description
  31. -----------
  32. Editor-only class. This is not present when running the game. It's used in the editor to properly edit and position collision shapes in :ref:`CollisionObject2D<class_collisionobject2d>`. This is not accessible from regular code. This class is for editing custom shape polygons.
  33. Member Function Description
  34. ---------------------------
  35. .. _class_CollisionPolygon2D_get_build_mode:
  36. - :ref:`int<class_int>` **get_build_mode** **(** **)** const
  37. Return whether the polygon is a :ref:`ConvexPolygonShape2D<class_convexpolygonshape2d>` (``build_mode==0``), or a :ref:`ConcavePolygonShape2D<class_concavepolygonshape2d>` (``build_mode==1``).
  38. .. _class_CollisionPolygon2D_get_collision_object_first_shape:
  39. - :ref:`int<class_int>` **get_collision_object_first_shape** **(** **)** const
  40. Return the index of the first shape generated by the editor.
  41. When ``build_mode`` is set to generate convex polygons, the shape shown in the editor may be decomposed into many convex polygons. In that case, a range of indexes is needed to directly access the :ref:`Shape2D<class_shape2d>`.
  42. When ``build_mode`` is set to generate concave polygons, there is only one :ref:`Shape2D<class_shape2d>` generated, so the start index and the end index are the same.
  43. .. _class_CollisionPolygon2D_get_collision_object_last_shape:
  44. - :ref:`int<class_int>` **get_collision_object_last_shape** **(** **)** const
  45. Return the index of the last shape generated by the editor.
  46. .. _class_CollisionPolygon2D_get_polygon:
  47. - :ref:`Vector2Array<class_vector2array>` **get_polygon** **(** **)** const
  48. Return the list of points that define the polygon.
  49. .. _class_CollisionPolygon2D_is_trigger:
  50. - :ref:`bool<class_bool>` **is_trigger** **(** **)** const
  51. Return whether this polygon is a trigger.
  52. .. _class_CollisionPolygon2D_set_build_mode:
  53. - void **set_build_mode** **(** :ref:`int<class_int>` build_mode **)**
  54. Set whether the polygon is to be a :ref:`ConvexPolygonShape2D<class_convexpolygonshape2d>` (``build_mode==0``), or a :ref:`ConcavePolygonShape2D<class_concavepolygonshape2d>` (``build_mode==1``).
  55. .. _class_CollisionPolygon2D_set_polygon:
  56. - void **set_polygon** **(** :ref:`Vector2Array<class_vector2array>` polygon **)**
  57. Set the array of points forming the polygon.
  58. 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.
  59. .. _class_CollisionPolygon2D_set_trigger:
  60. - void **set_trigger** **(** :ref:`bool<class_bool>` trigger **)**
  61. Set whether this polygon is a trigger. A trigger polygon detects collisions, but is otherwise unaffected by physics (i.e. colliding objects will not get blocked).