Finish signals section connected via code

This commit is contained in:
Daniel Siepmann 2024-03-26 11:15:21 +01:00
parent 9b42624c7d
commit b541ce8773
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 10 additions and 0 deletions

View file

@ -3,10 +3,17 @@ extends Sprite2D
var speed = 400
var angular_speed = PI
func _ready():
var timer = get_node('Timer')
timer.timeout.connect(_on_timer_timeout)
func _process(delta):
rotation += angular_speed * delta
var velocity = Vector2.UP.rotated(rotation) * speed
position += velocity * delta
func _on_timer_timeout():
visible = not visible
func _on_button_pressed():
set_process(not is_processing())

View file

@ -14,4 +14,7 @@ text = "Toggle motion"
[node name="Sprite2D" parent="." instance=ExtResource("1_1kdcd")]
position = Vector2(289, 187)
[node name="Timer" type="Timer" parent="Sprite2D"]
autostart = true
[connection signal="pressed" from="Button" to="Sprite2D" method="_on_button_pressed"]