Skip to content

1. Class Reference

Lucas Melo edited this page Jun 20, 2026 · 1 revision

Shadow2D - Class Reference

Inherits

Node2D

Brief Description

Node that provides simple 2D eliptical shadow.

Description

Draws an elliptical ground shadow under a Node2D actor. You control size, position, color, and gradient steps from the inspector or from code. Shadow textures with the same settings share one cached texture across all Shadow2D nodes. On ready, the node uses nearest texture filtering, show_behind_parent, and draw order suited for y-sorted scenes.

Constants

Name Value
MIN_SHADOW_SIZE 1

Properties

Type Name Default
float width 32.0
float height 16.0
Vector2 offset Vector2(0, 8)
Color color Color(0, 0, 0, 0.5)
int shadow_steps 1
float smoothing_amount 0.0
float step_falloff 0.3

Methods

Return Type Method
void apply_dimensions(float new_width, float new_height, Vector2 new_offset)
ImageTexture create_texture()

Constant Descriptions

MIN_SHADOW_SIZE: int = 1

Minimum width and height in pixels when the shadow texture is generated.


Property Descriptions

width: float = 32.0

Horizontal size of the shadow ellipse in pixels.

height: float = 16.0

Vertical size of the shadow ellipse in pixels.

offset: Vector2 = Vector2(0, 8)

Position offset from the parent node origin in pixels. Positive Y moves the shadow downward.

color: Color = Color(0, 0, 0, 0.5)

Shadow tint and base opacity. Alpha drives the overall strength of the shadow.

shadow_steps: int = 1

Number of gradient layers inside the ellipse. 1 draws a single smooth falloff. Higher values add stepped bands. Range: 1 to 16.

smoothing_amount: float = 0.0

Edge softness from 0.0 (sharp) to 1.0 (fully smooth). Also softens transitions between shadow steps when shadow_steps is above 1. Range: 0.0 to 1.0.

step_falloff: float = 0.3

Alpha multiplier applied per shadow step layer when shadow_steps is above 1. Range: 0.0 to 1.0.


Method Descriptions

apply_dimensions(float new_width, float new_height, Vector2 new_offset)

Sets width, height, and offset together in one texture refresh. Use this when you load actor data and want to avoid multiple rebuilds from separate property assignments.

create_texture()

Returns an ImageTexture built from the current property values. The texture is stored in the shared cache when the same settings are used again.

Clone this wiki locally