class_collisionobject2d.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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_pickable<class_CollisionObject2D_is_pickable>` **(** **)** const |
  25. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`is_shape_owner_disabled<class_CollisionObject2D_is_shape_owner_disabled>` **(** :ref:`int<class_int>` owner_id **)** const |
  27. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :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 |
  29. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`remove_shape_owner<class_CollisionObject2D_remove_shape_owner>` **(** :ref:`int<class_int>` owner_id **)** |
  31. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_pickable<class_CollisionObject2D_set_pickable>` **(** :ref:`bool<class_bool>` enabled **)** |
  33. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`shape_find_owner<class_CollisionObject2D_shape_find_owner>` **(** :ref:`int<class_int>` shape_index **)** const |
  35. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`shape_owner_add_shape<class_CollisionObject2D_shape_owner_add_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`Shape2D<class_shape2d>` shape **)** |
  37. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`shape_owner_clear_shapes<class_CollisionObject2D_shape_owner_clear_shapes>` **(** :ref:`int<class_int>` owner_id **)** |
  39. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Object<class_object>` | :ref:`shape_owner_get_owner<class_CollisionObject2D_shape_owner_get_owner>` **(** :ref:`int<class_int>` owner_id **)** const |
  41. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :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 |
  43. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`int<class_int>` | :ref:`shape_owner_get_shape_count<class_CollisionObject2D_shape_owner_get_shape_count>` **(** :ref:`int<class_int>` owner_id **)** const |
  45. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :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 |
  47. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Transform2D<class_transform2d>` | :ref:`shape_owner_get_transform<class_CollisionObject2D_shape_owner_get_transform>` **(** :ref:`int<class_int>` owner_id **)** const |
  49. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`shape_owner_remove_shape<class_CollisionObject2D_shape_owner_remove_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** |
  51. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`shape_owner_set_disabled<class_CollisionObject2D_shape_owner_set_disabled>` **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` disabled **)** |
  53. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | 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 **)** |
  55. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`shape_owner_set_transform<class_CollisionObject2D_shape_owner_set_transform>` **(** :ref:`int<class_int>` owner_id, :ref:`Transform2D<class_transform2d>` transform **)** |
  57. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. Signals
  59. -------
  60. - **input_event** **(** :ref:`Object<class_object>` viewport, :ref:`Object<class_object>` event, :ref:`int<class_int>` shape_idx **)**
  61. Emitted when an input event occurs and ``input_pickable`` is ``true``.
  62. - **mouse_entered** **(** **)**
  63. Emitted when the mouse pointer enters any of this object's shapes.
  64. - **mouse_exited** **(** **)**
  65. Emitted when the mouse pointer exits all this object's shapes.
  66. Member Variables
  67. ----------------
  68. - :ref:`bool<class_bool>` **input_pickable** - If [code]true[/code] 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. .. _class_CollisionObject2D_create_shape_owner:
  77. - :ref:`int<class_int>` **create_shape_owner** **(** :ref:`Object<class_object>` owner **)**
  78. Creates a new shape owner for the given object. Returns ``owner_id`` of the new owner for future reference.
  79. .. _class_CollisionObject2D_get_rid:
  80. - :ref:`RID<class_rid>` **get_rid** **(** **)** const
  81. Returns the object's :ref:`RID<class_rid>`.
  82. .. _class_CollisionObject2D_get_shape_owners:
  83. - :ref:`Array<class_array>` **get_shape_owners** **(** **)**
  84. 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.
  85. .. _class_CollisionObject2D_is_pickable:
  86. - :ref:`bool<class_bool>` **is_pickable** **(** **)** const
  87. Return whether this object is pickable.
  88. .. _class_CollisionObject2D_is_shape_owner_disabled:
  89. - :ref:`bool<class_bool>` **is_shape_owner_disabled** **(** :ref:`int<class_int>` owner_id **)** const
  90. If ``true`` the shape owner and its shapes are disabled.
  91. .. _class_CollisionObject2D_is_shape_owner_one_way_collision_enabled:
  92. - :ref:`bool<class_bool>` **is_shape_owner_one_way_collision_enabled** **(** :ref:`int<class_int>` owner_id **)** const
  93. .. _class_CollisionObject2D_remove_shape_owner:
  94. - void **remove_shape_owner** **(** :ref:`int<class_int>` owner_id **)**
  95. Removes the given shape owner.
  96. .. _class_CollisionObject2D_set_pickable:
  97. - void **set_pickable** **(** :ref:`bool<class_bool>` enabled **)**
  98. Set whether this object is pickable. A pickable object can detect the mouse pointer enter/leave it and, if the mouse is inside it, report input events.
  99. .. _class_CollisionObject2D_shape_find_owner:
  100. - :ref:`int<class_int>` **shape_find_owner** **(** :ref:`int<class_int>` shape_index **)** const
  101. Returns the ``owner_id`` of the given shape.
  102. .. _class_CollisionObject2D_shape_owner_add_shape:
  103. - void **shape_owner_add_shape** **(** :ref:`int<class_int>` owner_id, :ref:`Shape2D<class_shape2d>` shape **)**
  104. Adds a :ref:`Shape2D<class_shape2d>` to the shape owner.
  105. .. _class_CollisionObject2D_shape_owner_clear_shapes:
  106. - void **shape_owner_clear_shapes** **(** :ref:`int<class_int>` owner_id **)**
  107. Removes all shapes from the shape owner.
  108. .. _class_CollisionObject2D_shape_owner_get_owner:
  109. - :ref:`Object<class_object>` **shape_owner_get_owner** **(** :ref:`int<class_int>` owner_id **)** const
  110. Returns the parent object of the given shape owner.
  111. .. _class_CollisionObject2D_shape_owner_get_shape:
  112. - :ref:`Shape2D<class_shape2d>` **shape_owner_get_shape** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** const
  113. Returns the :ref:`Shape2D<class_shape2d>` with the given id from the given shape owner.
  114. .. _class_CollisionObject2D_shape_owner_get_shape_count:
  115. - :ref:`int<class_int>` **shape_owner_get_shape_count** **(** :ref:`int<class_int>` owner_id **)** const
  116. Returns the number of shapes the given shape owner contains.
  117. .. _class_CollisionObject2D_shape_owner_get_shape_index:
  118. - :ref:`int<class_int>` **shape_owner_get_shape_index** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** const
  119. .. _class_CollisionObject2D_shape_owner_get_transform:
  120. - :ref:`Transform2D<class_transform2d>` **shape_owner_get_transform** **(** :ref:`int<class_int>` owner_id **)** const
  121. Returns the shape owner's :ref:`Transform2D<class_transform2d>`.
  122. .. _class_CollisionObject2D_shape_owner_remove_shape:
  123. - void **shape_owner_remove_shape** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)**
  124. Removes a shape from the given shape owner.
  125. .. _class_CollisionObject2D_shape_owner_set_disabled:
  126. - void **shape_owner_set_disabled** **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` disabled **)**
  127. If ``true`` disables the given shape owner.
  128. .. _class_CollisionObject2D_shape_owner_set_one_way_collision:
  129. - void **shape_owner_set_one_way_collision** **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` enable **)**
  130. .. _class_CollisionObject2D_shape_owner_set_transform:
  131. - void **shape_owner_set_transform** **(** :ref:`int<class_int>` owner_id, :ref:`Transform2D<class_transform2d>` transform **)**
  132. Sets the :ref:`Transform2D<class_transform2d>` of the given shape owner.