CollisionObject2D

Inherits: Node2D < CanvasItem < Node < Object

Inherited By: Area2D, PhysicsBody2D

Nodo base para objetos de colisión 2D.

Descripción

CollisionObject2D es la clase base de los objetos de física 2D. Puede contener cualquier número de colisiones 2D Shape2D. Cada forma debe ser asignada a un propietario de la forma. El CollisionObject2D puede tener cualquier número de propietarios de formas. Los propietarios de formas no son nodos y no aparecen en el editor, pero son accesibles a través del código usando los métodos shape_owner_*.

Propiedades

int

collision_layer

1

int

collision_mask

1

bool

input_pickable

true

Métodos

void

_input_event ( Object viewport, InputEvent event, int shape_idx ) virtual

int

create_shape_owner ( Object owner )

bool

get_collision_layer_bit ( int bit ) const

bool

get_collision_mask_bit ( int bit ) const

RID

get_rid ( ) const

float

get_shape_owner_one_way_collision_margin ( int owner_id ) const

Array

get_shape_owners ( )

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_collision_layer_bit ( int bit, bool value )

void

set_collision_mask_bit ( int bit, bool value )

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_one_way_collision_margin ( int owner_id, float margin )

void

shape_owner_set_transform ( int owner_id, Transform2D transform )

Señales

Emitido cuando ocurre un evento de entrada. Requiere que input_pickable sea true y que se establezca al menos un bit collision_layer. Ver _input_event para más detalles.


  • mouse_entered ( )

Emitido cuando el puntero del ratón entra en cualquiera de las formas de este objeto. Requiere que input_pickable sea true y que al menos un bit collision_layer sea establecido.


  • mouse_exited ( )

Emitido cuando el puntero del ratón sale de todas las formas de este objeto. Requiere que input_pickable sea true y que al menos un bit collision_layer esté activado.

Descripciones de Propiedades

  • int collision_layer

Default

1

Setter

set_collision_layer(value)

Getter

get_collision_layer()

The physics layers this CollisionObject2D is in. Collision objects can exist in one or more of 32 different layers. See also collision_mask.

Note: A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See Collision layers and masks in the documentation for more information.


  • int collision_mask

Default

1

Setter

set_collision_mask(value)

Getter

get_collision_mask()

The physics layers this CollisionObject2D scans. Collision objects can scan one or more of 32 different layers. See also collision_layer.

Note: A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See Collision layers and masks in the documentation for more information.


  • bool input_pickable

Default

true

Setter

set_pickable(value)

Getter

is_pickable()

Si true, este objeto es seleccionable. Un objeto seleccionable puede detectar el puntero del ratón entrando y saliendo, y si el ratón está dentro de él, informar de los eventos de entrada. Requiere al menos un bit collision_layer para ser establecido.

Descripciones de Métodos

Acepta InputEvents no manipulados. Requiere que input_pickable sea true. shape_idx es el índice hijo de la Shape2D seleccionada. Conecta con la señal input_event para recoger fácilmente estos eventos.


Crea un nuevo dueño de la forma para el objeto dado. Devuelve owner_id del nuevo propietario para futuras referencias.


  • bool get_collision_layer_bit ( int bit ) const

Returns whether or not the specified bit of the collision_layer is set.


  • bool get_collision_mask_bit ( int bit ) const

Returns whether or not the specified bit of the collision_mask is set.


  • RID get_rid ( ) const

Devuelve el RID del objeto.


  • float get_shape_owner_one_way_collision_margin ( int owner_id ) const

Devuelve el one_way_collision_margin del propietario de la forma identificado por el owner_id dado.


  • Array get_shape_owners ( )

Devuelve un Array de identificadores owner_id. Puedes usar estos identificadores en otros métodos que toman owner_id como argumento.


  • bool is_shape_owner_disabled ( int owner_id ) const

Si true, el propietario de la forma y sus formas se desactivan.


  • bool is_shape_owner_one_way_collision_enabled ( int owner_id ) const

Devuelve true si las colisiones para el propietario de la forma originadas por este CollisionObject2D no serán reportadas como colisionadas con los CollisionObject2Ds.


  • void remove_shape_owner ( int owner_id )

Elimina al dueño de la forma dada.


  • void set_collision_layer_bit ( int bit, bool value )

If value is true, sets the specified bit in the the collision_layer.

If value is false, clears the specified bit in the the collision_layer.


  • void set_collision_mask_bit ( int bit, bool value )

If value is true, sets the specified bit in the the collision_mask.

If value is false, clears the specified bit in the the collision_mask.


  • int shape_find_owner ( int shape_index ) const

Devuelve el owner_id de la forma dada.


  • void shape_owner_add_shape ( int owner_id, Shape2D shape )

Añade un Shape2D al dueño de la forma.


  • void shape_owner_clear_shapes ( int owner_id )

Elimina todas las formas del dueño de la forma.


  • Object shape_owner_get_owner ( int owner_id ) const

Devuelve el objeto padre del propietario de la forma dada.


  • Shape2D shape_owner_get_shape ( int owner_id, int shape_id ) const

Devuelve el Shape2D con la identificación dada por el dueño de la forma.


  • int shape_owner_get_shape_count ( int owner_id ) const

Devuelve el número de formas que contiene el propietario de la forma dada.


  • int shape_owner_get_shape_index ( int owner_id, int shape_id ) const

Devuelve el índice de hijos de la Shape2D con el id dado del propietario de la forma.


Devuelve la forma del dueño Transform2D.


  • void shape_owner_remove_shape ( int owner_id, int shape_id )

Quita una forma del dueño de la forma dada.


  • void shape_owner_set_disabled ( int owner_id, bool disabled )

Si true, deshabilita al dueño de la forma dada.


  • void shape_owner_set_one_way_collision ( int owner_id, bool enable )

Si enable es true, las colisiones para el propietario de la forma originadas por este CollisionObject2D no se comunicarán como colisiones con las de CollisionObject2D.


  • void shape_owner_set_one_way_collision_margin ( int owner_id, float margin )

Establece el one_way_collision_margin del propietario de la forma identificado por el owner_id dado a los píxeles del margin.


  • void shape_owner_set_transform ( int owner_id, Transform2D transform )

Establece la Transform2D del propietario de la forma dada.