falling block has a delay before falling
This commit is contained in:
parent
124b5e16aa
commit
c3f32de2df
7 changed files with 216 additions and 40 deletions
|
@ -3,16 +3,27 @@ extends KinematicBody2D
|
|||
var fall = false
|
||||
export var fall_speed = 0.5
|
||||
onready var startpos = position
|
||||
onready var timer = $Timer
|
||||
|
||||
func _physics_process(delta):
|
||||
if fall:
|
||||
position.y += fall_speed
|
||||
Debug.print($Timer.get_time_left())
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
if area.is_in_group("player"):
|
||||
fall = true
|
||||
$Timer.start()
|
||||
|
||||
|
||||
func _on_VisibilityNotifier2D_screen_exited():
|
||||
position = startpos
|
||||
fall = false
|
||||
|
||||
|
||||
func _on_Timer_timeout():
|
||||
fall = true
|
||||
|
||||
|
||||
func _on_Area2D_area_exited(area):
|
||||
$Timer.stop()
|
||||
|
||||
|
|
|
@ -35,5 +35,11 @@ collision_mask = 2
|
|||
position = Vector2( 4, -0.5 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 0.15
|
||||
one_shot = true
|
||||
|
||||
[connection signal="screen_exited" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"]
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
||||
[connection signal="area_exited" from="Area2D" to="." method="_on_Area2D_area_exited"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue