Finish signals section connected via scene/editor
This commit is contained in:
parent
bbeb63cc62
commit
9b42624c7d
2 changed files with 21 additions and 12 deletions
|
@ -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'):
|
|
||||||
position -= velocity * delta
|
|
||||||
|
|
||||||
|
func _on_button_pressed():
|
||||||
|
set_process(not is_processing())
|
||||||
|
|
17
scripting_first_script/node_2d.tscn
Normal file
17
scripting_first_script/node_2d.tscn
Normal 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"]
|
Loading…
Reference in a new issue