Finish signals section connected via scene/editor

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

View file

@ -4,17 +4,9 @@ var speed = 400
var angular_speed = PI var angular_speed = PI
func _process(delta): func _process(delta):
var direction = 0 rotation += angular_speed * delta
if Input.is_action_pressed('ui_left'):
direction = -1
if Input.is_action_pressed('ui_right'):
direction = +1
rotation += angular_speed * direction * delta
var velocity = Vector2.UP.rotated(rotation) * speed var velocity = Vector2.UP.rotated(rotation) * speed
if Input.is_action_pressed('ui_up'):
position += velocity * delta position += velocity * delta
if Input.is_action_pressed('ui_down'): func _on_button_pressed():
position -= velocity * delta set_process(not is_processing())

View file

@ -0,0 +1,17 @@
[gd_scene load_steps=2 format=3 uid="uid://c8sxdckrhknyo"]
[ext_resource type="PackedScene" uid="uid://bxxuj5sw4p1oy" path="res://sprite_2d.tscn" id="1_1kdcd"]
[node name="Node2D" type="Node2D"]
[node name="Button" type="Button" parent="."]
offset_left = 53.0
offset_top = 51.0
offset_right = 172.0
offset_bottom = 95.0
text = "Toggle motion"
[node name="Sprite2D" parent="." instance=ExtResource("1_1kdcd")]
position = Vector2(289, 187)
[connection signal="pressed" from="Button" to="Sprite2D" method="_on_button_pressed"]