CollisionObject2D¶
Inherits: Node2D < CanvasItem < Node < Object
Inherited By: Area2D, PhysicsBody2D
Category: Core
Brief Description¶
Base node for 2D collisionables.
Member Functions¶
Signals¶
- input_event ( Object viewport, InputEvent event, int shape_idx )
This signal triggers when an input event fires over a shape. The first parameter is the viewport where the event took place. The second holds the input event received, and the third the shape of this object where it happened.
- mouse_enter ( )
This event fires only once when the mouse pointer enters any shape of this object.
- mouse_exit ( )
This event fires only once when the mouse pointer exits all shapes of this object.
Description¶
CollisionObject2D is the base class for 2D physics collisionables. They can hold any number of 2D collision shapes. Usually, they are edited by placing CollisionShape2D and/or CollisionPolygon2D nodes as children. Such nodes are for reference and not present outside the editor, so code should use the regular shape API.
Member Function Description¶
- void _input_event ( Object viewport, InputEvent event, int shape_idx ) virtual
Creates new holder for the shapes. Argument is a CollisionShape2D node. It will return owner_id which usually you will want to save for later use.
- RID get_rid ( ) const
Return the RID of this object.
- Array get_shape_owners ( )
Shape owner is a node which is holding concrete shape resources. This method will return an array which is holding an integer numbers that are representing unique ID of each owner. You can use those ids when you are using others shape_owner methods.
- bool is_pickable ( ) const
Return whether this object is pickable.
- void remove_shape_owner ( int owner_id )
- void set_pickable ( bool enabled )
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.
- void shape_owner_clear_shapes ( int owner_id )
Will remove all the shapes associated with given owner.
Will return a Shape2D. First argument owner_id is an integer that can be obtained from get_shape_owners. Shape_id is a position of the shape inside owner; it’s a value in range from 0 to shape_owner_get_shape_count.
Returns number of shapes to which given owner is associated to.
- Transform2D shape_owner_get_transform ( int owner_id ) const
Will return Transform2D of an owner node.
Removes related shape from the owner.
- void shape_owner_set_transform ( int owner_id, Transform2D transform )