Make doors auto-close after a while

This commit is contained in:
Hamcha 2020-07-07 00:09:45 +02:00
parent 958e91df75
commit b611f7f4d0
Signed by: hamcha
GPG key ID: 41467804B19A3315
2 changed files with 11 additions and 0 deletions

View file

@ -13,6 +13,8 @@ func _animation_finished():
# Disable collider # Disable collider
collision_layer = 16 collision_layer = 16
collision_mask = 16 collision_mask = 16
# Start timer for auto-close
$Timer.start()
else: else:
# Enable collider # Enable collider
collision_mask = 1 collision_mask = 1
@ -22,3 +24,7 @@ func _input_event(viewport, event, shape_idx):
if event is InputEventMouseButton and event.pressed: if event is InputEventMouseButton and event.pressed:
set_open($Sprite.animation == "close") set_open($Sprite.animation == "close")
func _close_timer_triggered():
$Sprite.play("close")

View file

@ -53,4 +53,9 @@ centered = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 16, 16 ) position = Vector2( 16, 16 )
shape = SubResource( 7 ) shape = SubResource( 7 )
[node name="Timer" type="Timer" parent="."]
wait_time = 5.0
one_shot = true
[connection signal="animation_finished" from="Sprite" to="." method="_animation_finished"] [connection signal="animation_finished" from="Sprite" to="." method="_animation_finished"]
[connection signal="timeout" from="Timer" to="." method="_close_timer_triggered"]