falling blocks now have an animation before reappearing
This commit is contained in:
parent
f8ce5ee5cf
commit
7c94312749
2 changed files with 54 additions and 6 deletions
|
@ -6,6 +6,8 @@ onready var startpos = position
|
|||
onready var fall_timer = $FallTimer
|
||||
onready var refresh_timer = $RefreshTimer
|
||||
onready var crush_area = $CrushArea
|
||||
onready var collision_shape = $CollisionShape2D
|
||||
onready var anims = $AnimationPlayer
|
||||
|
||||
func _physics_process(delta):
|
||||
#Fall
|
||||
|
@ -17,6 +19,9 @@ func _physics_process(delta):
|
|||
var player = area.get_parent()
|
||||
if player.is_on_floor():
|
||||
player.die()
|
||||
#Play animation when disappearing
|
||||
if !refresh_timer.is_stopped() && refresh_timer.get_time_left() <= 0.6:
|
||||
anims.play("disappear")
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
if area.is_in_group("player"):
|
||||
|
@ -28,8 +33,12 @@ func _on_VisibilityNotifier2D_screen_exited():
|
|||
fall = false
|
||||
|
||||
func _on_RefreshTimer_timeout():
|
||||
position = startpos
|
||||
collision_shape.disabled = true # disable collision
|
||||
# re-enable collision and set position at end of frame
|
||||
call_deferred("set_position", startpos)
|
||||
collision_shape.call_deferred("set_disabled", false)
|
||||
fall = false
|
||||
anims.play("idle")
|
||||
|
||||
func _on_FallTimer_timeout():
|
||||
fall = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue