Finish signals section connected via code
This commit is contained in:
parent
9b42624c7d
commit
b541ce8773
2 changed files with 10 additions and 0 deletions
|
@ -3,10 +3,17 @@ extends Sprite2D
|
||||||
var speed = 400
|
var speed = 400
|
||||||
var angular_speed = PI
|
var angular_speed = PI
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var timer = get_node('Timer')
|
||||||
|
timer.timeout.connect(_on_timer_timeout)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
rotation += angular_speed * delta
|
rotation += angular_speed * delta
|
||||||
var velocity = Vector2.UP.rotated(rotation) * speed
|
var velocity = Vector2.UP.rotated(rotation) * speed
|
||||||
position += velocity * delta
|
position += velocity * delta
|
||||||
|
|
||||||
|
func _on_timer_timeout():
|
||||||
|
visible = not visible
|
||||||
|
|
||||||
func _on_button_pressed():
|
func _on_button_pressed():
|
||||||
set_process(not is_processing())
|
set_process(not is_processing())
|
||||||
|
|
|
@ -14,4 +14,7 @@ text = "Toggle motion"
|
||||||
[node name="Sprite2D" parent="." instance=ExtResource("1_1kdcd")]
|
[node name="Sprite2D" parent="." instance=ExtResource("1_1kdcd")]
|
||||||
position = Vector2(289, 187)
|
position = Vector2(289, 187)
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="Sprite2D"]
|
||||||
|
autostart = true
|
||||||
|
|
||||||
[connection signal="pressed" from="Button" to="Sprite2D" method="_on_button_pressed"]
|
[connection signal="pressed" from="Button" to="Sprite2D" method="_on_button_pressed"]
|
||||||
|
|
Loading…
Reference in a new issue