Files
godot-demo-projects/2d/particles/pause.gd
Hugo Locurcio bac1e69164 Use static typing in all demos (#1063)
This leads to code that is easier to understand and runs
faster thanks to GDScript's typed instructions.

The untyped declaration warning is now enabled on all projects
where type hints were added. All projects currently run without
any untyped declration warnings.

Dodge the Creeps and Squash the Creeps demos intentionally don't
use type hints to match the documentation, where type hints haven't
been adopted yet (given its beginner focus).
2024-06-01 12:12:18 +02:00

28 lines
1.2 KiB
GDScript

extends Label
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_pause"):
get_tree().paused = not get_tree().paused
if event.is_action_pressed("toggle_trails"):
# Particles disappear if trail type is changed while paused.
# Prevent changing particle type while paused to avoid confusion.
for particles in get_tree().get_nodes_in_group("trailable_particles"):
particles.trail_enabled = not particles.trail_enabled
if event.is_action_pressed("increase_trail_length"):
# Particles disappear if trail type is changed while paused.
# Prevent changing particle type while paused to avoid confusion.
for particles in get_tree().get_nodes_in_group("trailable_particles"):
particles.trail_lifetime = clampf(particles.trail_lifetime + 0.05, 0.1, 1.0)
if event.is_action_pressed("decrease_trail_length"):
# Particles disappear if trail type is changed while paused.
# Prevent changing particle type while paused to avoid confusion.
for particles in get_tree().get_nodes_in_group("trailable_particles"):
particles.trail_lifetime = clampf(particles.trail_lifetime - 0.05, 0.1, 1.0)
if event.is_action_pressed("toggle_glow"):
get_node("../..").environment.glow_enabled = not get_node("../..").environment.glow_enabled