Make doors auto-close after a while
This commit is contained in:
parent
958e91df75
commit
b611f7f4d0
2 changed files with 11 additions and 0 deletions
|
@ -13,6 +13,8 @@ func _animation_finished():
|
|||
# Disable collider
|
||||
collision_layer = 16
|
||||
collision_mask = 16
|
||||
# Start timer for auto-close
|
||||
$Timer.start()
|
||||
else:
|
||||
# Enable collider
|
||||
collision_mask = 1
|
||||
|
@ -22,3 +24,7 @@ func _input_event(viewport, event, shape_idx):
|
|||
if event is InputEventMouseButton and event.pressed:
|
||||
set_open($Sprite.animation == "close")
|
||||
|
||||
|
||||
|
||||
func _close_timer_triggered():
|
||||
$Sprite.play("close")
|
||||
|
|
|
@ -53,4 +53,9 @@ centered = false
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 16, 16 )
|
||||
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="timeout" from="Timer" to="." method="_close_timer_triggered"]
|
||||
|
|
Reference in a new issue