CollisionPolygon2D

Inherits: Node2D < CanvasItem < Node < Object

Category: Core

Brief Description

Editor-only class for easy editing of collision polygons.

Member Functions

int get_build_mode ( ) const
PoolVector2Array get_polygon ( ) const
bool is_disabled ( ) const
bool is_one_way_collision_enabled ( ) const
void set_build_mode ( int build_mode )
void set_disabled ( bool disabled )
void set_one_way_collision ( bool enabled )
void set_polygon ( PoolVector2Array polygon )

Member Variables

Description

Editor-only class. This is not present when running the game. It’s used in the editor to properly edit and position collision shapes in CollisionObject2D. This is not accessible from regular code. This class is for editing custom shape polygons.

Member Function Description

  • int get_build_mode ( ) const

Return whether the polygon is a ConvexPolygonShape2D (build_mode==0), or a ConcavePolygonShape2D (build_mode==1).

Return the list of points that define the polygon.

  • bool is_disabled ( ) const
  • bool is_one_way_collision_enabled ( ) const
  • void set_build_mode ( int build_mode )

Set whether the polygon is to be a ConvexPolygonShape2D (build_mode==0), or a ConcavePolygonShape2D (build_mode==1).

  • void set_disabled ( bool disabled )
  • void set_one_way_collision ( bool enabled )

Set the array of points forming the polygon.

When editing the point list via the editor, depending on get_build_mode, it has to be a list of points (for build_mode==0), or a list of lines (for build_mode==1). In the second case, the even elements of the array define the start point of the line, and the odd elements the end point.