VisualShape2D¶
Inherits: Node2D < CanvasItem < Node < Object
Draws any Shape2D resource. Useful for quick prototyping and debugging.
Description¶
This is a node with the entire purpose of rendering Shape2D resources just like collision shapes are drawn in the editor, yet it’s also possible to override the color per each node rather than globally with this class. You may use Godot’s Polygon2D node which is much more suitable for polygon editing and drawing with textures, as any shape can be represented with it.
Properties¶
Color | color | Color( 1, 1, 1, 1 ) |
bool | debug_sync_visible_collision_shapes | false |
bool | debug_use_default_color | false |
Shape2D | shape | |
bool | use_parent_shape | false |
Methods¶
bool | update_parent_shape ( ) |
Property Descriptions¶
- Color color
Default | Color( 1, 1, 1, 1 ) |
Setter | set_color(value) |
Getter | get_color() |
The fill color used to draw the shape.
- bool debug_sync_visible_collision_shapes
Default | false |
Setter | set_debug_sync_visible_collision_shapes(value) |
Getter | is_debug_sync_visible_collision_shapes() |
If true
, respects the “Visible Collision Shapes” option so that the shape is only drawn when the option is enabled while the game is running.
Note: available in debug builds only.
- bool debug_use_default_color
Default | false |
Setter | set_debug_use_default_color(value) |
Getter | is_using_debug_default_color() |
If true
, this overrides the color with the color used to draw the collision shapes.
Note: available in debug builds only.
- Shape2D shape
Setter | set_shape(value) |
Getter | get_shape() |
The shape resource used as a reference to draw. The drawing method is specific for each shape and the properties must be configured per shape.
- bool use_parent_shape
Default | false |
Setter | set_use_parent_shape(value) |
Getter | is_using_parent_shape() |
If true
, the shape is fetched from the parent node to draw instead of its own shape. The parent node must have either shape
as Shape2D property or points
, polygon
as PoolVector2Array property defined, else nothing is drawn.
Method Descriptions¶
- bool update_parent_shape ( )
Forces to update the shape from parent node. This is called automatically each idle frame if use_parent_shape is enabled. Updating the shape each frame may be costly, so you can disable this behavior with set_process(false)
on this node, and update the shape manually with this method when needed.