CollisionObject2D¶
Inherits: Node2D < CanvasItem < Node < Object
Inherited By: Area2D, PhysicsBody2D
Category: Core
Brief Description¶
Base node for 2D collision objects.
Member Functions¶
Signals¶
Emitted when an input event occurs and input_pickable is true. See _input_event for details.
- mouse_entered ( )
Emitted when the mouse pointer enters any of this object’s shapes.
- mouse_exited ( )
Emitted when the mouse pointer exits all this object’s shapes.
Member Variables¶
- bool input_pickable - If
truethis object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events.
Description¶
CollisionObject2D is the base class for 2D physics objects. It can hold any number of 2D collision Shape2Ds. 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.
Member Function Description¶
- void _input_event ( Object viewport, InputEvent event, int shape_idx ) virtual
Accepts unhandled InputEvents. shape_idx is the child index of the clicked Shape2D. Connect to the input_event signal to easily pick up these events.
Creates a new shape owner for the given object. Returns owner_id of the new owner for future reference.
- RID get_rid ( ) const
Returns the object’s RID.
- Array get_shape_owners ( )
Returns an Array of owner_id identifiers. You can use these ids in other methods that take owner_id as an argument.
If true the shape owner and its shapes are disabled.
Returns true if collisions for the shape owner originating from this CollisionObject2D will not be reported to collided with CollisionObject2Ds.
- void remove_shape_owner ( int owner_id )
Removes the given shape owner.
Returns the owner_id of the given shape.
Adds a Shape2D to the shape owner.
- void shape_owner_clear_shapes ( int owner_id )
Removes all shapes from the shape owner.
Returns the parent object of the given shape owner.
Returns the Shape2D with the given id from the given shape owner.
Returns the number of shapes the given shape owner contains.
Returns the child index of the Shape2D with the given id from the given shape owner.
- Transform2D shape_owner_get_transform ( int owner_id ) const
Returns the shape owner’s Transform2D.
Removes a shape from the given shape owner.
If true disables the given shape owner.
If enable is true, collisions for the shape owner originating from this CollisionObject2D will not be reported to collided with CollisionObject2Ds.
- void shape_owner_set_transform ( int owner_id, Transform2D transform )
Sets the Transform2D of the given shape owner.