CollisionObject2D

Inherits: Node2D < CanvasItem < Node < Object

Inherited By: Area2D, PhysicsBody2D

Category: Core

Brief Description

Base node for 2D collisionables.

Member Functions

void _input_event ( Object viewport, InputEvent event, int shape_idx ) virtual
int create_shape_owner ( Object owner )
RID get_rid ( ) const
Array get_shape_owners ( )
bool is_pickable ( ) const
bool is_shape_owner_disabled ( int owner_id ) const
bool is_shape_owner_one_way_collision_enabled ( int owner_id ) const
void remove_shape_owner ( int owner_id )
void set_pickable ( bool enabled )
int shape_find_owner ( int shape_index ) const
void shape_owner_add_shape ( int owner_id, Shape2D shape )
void shape_owner_clear_shapes ( int owner_id )
Object shape_owner_get_owner ( int owner_id ) const
Shape2D shape_owner_get_shape ( int owner_id, int shape_id ) const
int shape_owner_get_shape_count ( int owner_id ) const
int shape_owner_get_shape_index ( int owner_id, int shape_id ) const
Transform2D shape_owner_get_transform ( int owner_id ) const
void shape_owner_remove_shape ( int owner_id, int shape_id )
void shape_owner_set_disabled ( int owner_id, bool disabled )
void shape_owner_set_one_way_collision ( int owner_id, bool enable )
void shape_owner_set_transform ( int owner_id, Transform2D transform )

Signals

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

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.

  • bool is_shape_owner_disabled ( int owner_id ) const
  • bool is_shape_owner_one_way_collision_enabled ( int owner_id ) const
  • 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.

  • int shape_find_owner ( int shape_index ) const
  • void shape_owner_add_shape ( int owner_id, Shape2D shape )
  • void shape_owner_clear_shapes ( int owner_id )

Will remove all the shapes associated with given owner.

  • Object shape_owner_get_owner ( int owner_id ) const
  • Shape2D shape_owner_get_shape ( int owner_id, int shape_id ) const

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.

  • int shape_owner_get_shape_count ( int owner_id ) const

Returns number of shapes to which given owner is associated to.

  • int shape_owner_get_shape_index ( int owner_id, int shape_id ) const

Will return Transform2D of an owner node.

  • void shape_owner_remove_shape ( int owner_id, int shape_id )

Removes related shape from the owner.

  • void shape_owner_set_disabled ( int owner_id, bool disabled )
  • void shape_owner_set_one_way_collision ( int owner_id, bool enable )
  • void shape_owner_set_transform ( int owner_id, Transform2D transform )