Files
godot-demo-projects/2d/lights_and_shadows/light_shadows.gd
2025-10-11 05:03:59 -07:00

18 lines
753 B
GDScript

extends Node2D
func _input(input_event: InputEvent) -> void:
if input_event.is_action_pressed(&"toggle_directional_light"):
$DirectionalLight2D.visible = not $DirectionalLight2D.visible
if input_event.is_action_pressed(&"toggle_point_lights"):
for point_light in get_tree().get_nodes_in_group(&"point_light"):
point_light.visible = not point_light.visible
if input_event.is_action_pressed(&"cycle_directional_light_shadows_quality"):
$DirectionalLight2D.shadow_filter = wrapi($DirectionalLight2D.shadow_filter + 1, 0, 3)
if input_event.is_action_pressed(&"cycle_point_light_shadows_quality"):
for point_light in get_tree().get_nodes_in_group(&"point_light"):
point_light.shadow_filter = wrapi(point_light.shadow_filter + 1, 0, 3)