class_collisionobject2d.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the CollisionObject2D.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_CollisionObject2D:
  5. CollisionObject2D
  6. =================
  7. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Inherited By:** :ref:`Area2D<class_area2d>`, :ref:`PhysicsBody2D<class_physicsbody2d>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Base node for 2D collision objects.
  13. Member Functions
  14. ----------------
  15. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`_input_event<class_CollisionObject2D__input_event>` **(** :ref:`Object<class_object>` viewport, :ref:`InputEvent<class_inputevent>` event, :ref:`int<class_int>` shape_idx **)** virtual |
  17. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`int<class_int>` | :ref:`create_shape_owner<class_CollisionObject2D_create_shape_owner>` **(** :ref:`Object<class_object>` owner **)** |
  19. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`RID<class_rid>` | :ref:`get_rid<class_CollisionObject2D_get_rid>` **(** **)** const |
  21. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`Array<class_array>` | :ref:`get_shape_owners<class_CollisionObject2D_get_shape_owners>` **(** **)** |
  23. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`is_shape_owner_disabled<class_CollisionObject2D_is_shape_owner_disabled>` **(** :ref:`int<class_int>` owner_id **)** const |
  25. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`is_shape_owner_one_way_collision_enabled<class_CollisionObject2D_is_shape_owner_one_way_collision_enabled>` **(** :ref:`int<class_int>` owner_id **)** const |
  27. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`remove_shape_owner<class_CollisionObject2D_remove_shape_owner>` **(** :ref:`int<class_int>` owner_id **)** |
  29. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`shape_find_owner<class_CollisionObject2D_shape_find_owner>` **(** :ref:`int<class_int>` shape_index **)** const |
  31. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`shape_owner_add_shape<class_CollisionObject2D_shape_owner_add_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`Shape2D<class_shape2d>` shape **)** |
  33. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`shape_owner_clear_shapes<class_CollisionObject2D_shape_owner_clear_shapes>` **(** :ref:`int<class_int>` owner_id **)** |
  35. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Object<class_object>` | :ref:`shape_owner_get_owner<class_CollisionObject2D_shape_owner_get_owner>` **(** :ref:`int<class_int>` owner_id **)** const |
  37. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Shape2D<class_shape2d>` | :ref:`shape_owner_get_shape<class_CollisionObject2D_shape_owner_get_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** const |
  39. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`int<class_int>` | :ref:`shape_owner_get_shape_count<class_CollisionObject2D_shape_owner_get_shape_count>` **(** :ref:`int<class_int>` owner_id **)** const |
  41. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`shape_owner_get_shape_index<class_CollisionObject2D_shape_owner_get_shape_index>` **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** const |
  43. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Transform2D<class_transform2d>` | :ref:`shape_owner_get_transform<class_CollisionObject2D_shape_owner_get_transform>` **(** :ref:`int<class_int>` owner_id **)** const |
  45. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`shape_owner_remove_shape<class_CollisionObject2D_shape_owner_remove_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** |
  47. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`shape_owner_set_disabled<class_CollisionObject2D_shape_owner_set_disabled>` **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` disabled **)** |
  49. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`shape_owner_set_one_way_collision<class_CollisionObject2D_shape_owner_set_one_way_collision>` **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` enable **)** |
  51. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`shape_owner_set_transform<class_CollisionObject2D_shape_owner_set_transform>` **(** :ref:`int<class_int>` owner_id, :ref:`Transform2D<class_transform2d>` transform **)** |
  53. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. Signals
  55. -------
  56. .. _class_CollisionObject2D_input_event:
  57. - **input_event** **(** :ref:`Object<class_object>` viewport, :ref:`Object<class_object>` event, :ref:`int<class_int>` shape_idx **)**
  58. Emitted when an input event occurs and ``input_pickable`` is ``true``. See :ref:`_input_event<class_CollisionObject2D__input_event>` for details.
  59. .. _class_CollisionObject2D_mouse_entered:
  60. - **mouse_entered** **(** **)**
  61. Emitted when the mouse pointer enters any of this object's shapes.
  62. .. _class_CollisionObject2D_mouse_exited:
  63. - **mouse_exited** **(** **)**
  64. Emitted when the mouse pointer exits all this object's shapes.
  65. Member Variables
  66. ----------------
  67. .. _class_CollisionObject2D_input_pickable:
  68. - :ref:`bool<class_bool>` **input_pickable** - If ``true`` this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events.
  69. Description
  70. -----------
  71. CollisionObject2D is the base class for 2D physics objects. It can hold any number of 2D collision :ref:`Shape2D<class_shape2d>`\ s. Each shape must be assigned to a *shape owner*. The CollisionObject2D can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the ``shape_owner_*`` methods.
  72. Member Function Description
  73. ---------------------------
  74. .. _class_CollisionObject2D__input_event:
  75. - void **_input_event** **(** :ref:`Object<class_object>` viewport, :ref:`InputEvent<class_inputevent>` event, :ref:`int<class_int>` shape_idx **)** virtual
  76. Accepts unhandled :ref:`InputEvent<class_inputevent>`\ s. ``shape_idx`` is the child index of the clicked :ref:`Shape2D<class_shape2d>`. Connect to the ``input_event`` signal to easily pick up these events.
  77. .. _class_CollisionObject2D_create_shape_owner:
  78. - :ref:`int<class_int>` **create_shape_owner** **(** :ref:`Object<class_object>` owner **)**
  79. Creates a new shape owner for the given object. Returns ``owner_id`` of the new owner for future reference.
  80. .. _class_CollisionObject2D_get_rid:
  81. - :ref:`RID<class_rid>` **get_rid** **(** **)** const
  82. Returns the object's :ref:`RID<class_rid>`.
  83. .. _class_CollisionObject2D_get_shape_owners:
  84. - :ref:`Array<class_array>` **get_shape_owners** **(** **)**
  85. Returns an :ref:`Array<class_array>` of ``owner_id`` identifiers. You can use these ids in other methods that take ``owner_id`` as an argument.
  86. .. _class_CollisionObject2D_is_shape_owner_disabled:
  87. - :ref:`bool<class_bool>` **is_shape_owner_disabled** **(** :ref:`int<class_int>` owner_id **)** const
  88. If ``true`` the shape owner and its shapes are disabled.
  89. .. _class_CollisionObject2D_is_shape_owner_one_way_collision_enabled:
  90. - :ref:`bool<class_bool>` **is_shape_owner_one_way_collision_enabled** **(** :ref:`int<class_int>` owner_id **)** const
  91. Returns ``true`` if collisions for the shape owner originating from this ``CollisionObject2D`` will not be reported to collided with ``CollisionObject2D``\ s.
  92. .. _class_CollisionObject2D_remove_shape_owner:
  93. - void **remove_shape_owner** **(** :ref:`int<class_int>` owner_id **)**
  94. Removes the given shape owner.
  95. .. _class_CollisionObject2D_shape_find_owner:
  96. - :ref:`int<class_int>` **shape_find_owner** **(** :ref:`int<class_int>` shape_index **)** const
  97. Returns the ``owner_id`` of the given shape.
  98. .. _class_CollisionObject2D_shape_owner_add_shape:
  99. - void **shape_owner_add_shape** **(** :ref:`int<class_int>` owner_id, :ref:`Shape2D<class_shape2d>` shape **)**
  100. Adds a :ref:`Shape2D<class_shape2d>` to the shape owner.
  101. .. _class_CollisionObject2D_shape_owner_clear_shapes:
  102. - void **shape_owner_clear_shapes** **(** :ref:`int<class_int>` owner_id **)**
  103. Removes all shapes from the shape owner.
  104. .. _class_CollisionObject2D_shape_owner_get_owner:
  105. - :ref:`Object<class_object>` **shape_owner_get_owner** **(** :ref:`int<class_int>` owner_id **)** const
  106. Returns the parent object of the given shape owner.
  107. .. _class_CollisionObject2D_shape_owner_get_shape:
  108. - :ref:`Shape2D<class_shape2d>` **shape_owner_get_shape** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** const
  109. Returns the :ref:`Shape2D<class_shape2d>` with the given id from the given shape owner.
  110. .. _class_CollisionObject2D_shape_owner_get_shape_count:
  111. - :ref:`int<class_int>` **shape_owner_get_shape_count** **(** :ref:`int<class_int>` owner_id **)** const
  112. Returns the number of shapes the given shape owner contains.
  113. .. _class_CollisionObject2D_shape_owner_get_shape_index:
  114. - :ref:`int<class_int>` **shape_owner_get_shape_index** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** const
  115. Returns the child index of the :ref:`Shape2D<class_shape2d>` with the given id from the given shape owner.
  116. .. _class_CollisionObject2D_shape_owner_get_transform:
  117. - :ref:`Transform2D<class_transform2d>` **shape_owner_get_transform** **(** :ref:`int<class_int>` owner_id **)** const
  118. Returns the shape owner's :ref:`Transform2D<class_transform2d>`.
  119. .. _class_CollisionObject2D_shape_owner_remove_shape:
  120. - void **shape_owner_remove_shape** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)**
  121. Removes a shape from the given shape owner.
  122. .. _class_CollisionObject2D_shape_owner_set_disabled:
  123. - void **shape_owner_set_disabled** **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` disabled **)**
  124. If ``true`` disables the given shape owner.
  125. .. _class_CollisionObject2D_shape_owner_set_one_way_collision:
  126. - void **shape_owner_set_one_way_collision** **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` enable **)**
  127. If ``enable`` is ``true``, collisions for the shape owner originating from this ``CollisionObject2D`` will not be reported to collided with ``CollisionObject2D``\ s.
  128. .. _class_CollisionObject2D_shape_owner_set_transform:
  129. - void **shape_owner_set_transform** **(** :ref:`int<class_int>` owner_id, :ref:`Transform2D<class_transform2d>` transform **)**
  130. Sets the :ref:`Transform2D<class_transform2d>` of the given shape owner.