fix another arrow crash (closes #72)

This commit is contained in:
Haze Weathers 2023-03-22 11:53:16 -04:00
parent 563bb46a44
commit 094584e1b7

View file

@ -59,22 +59,24 @@ func _on_Hitbox_area_entered(area):
queue_free() queue_free()
func _persist_trail(): func _persist_trail():
var particles = $DustParticles # don't do this twice to prevent crash
remove_child(particles) if not is_queued_for_deletion():
get_parent().add_child(particles) # make particles a sibling so it lives a bit longer than arrow
particles.global_position = global_position var particles = $DustParticles
particles.emitting = false remove_child(particles)
get_tree().create_timer(particles.lifetime, false).connect("timeout", particles, "queue_free") get_parent().add_child(particles)
particles.global_position = global_position
particles.emitting = false
# free particles once they have gone through their lifetime
get_tree().create_timer(particles.lifetime, false).connect("timeout", particles, "queue_free")
func _make_sparks(): func _make_sparks():
# return if this has already happened to avoid crash # don't do this twice to prevent crash
if is_queued_for_deletion(): if not is_queued_for_deletion():
return var particles = $SparkParticles
remove_child(particles)
var particles = $SparkParticles particles.global_position = global_position + particles.position * scale.x
remove_child(particles) particles.emitting = true
particles.global_position = global_position + particles.position * scale.x get_parent().add_child(particles)
particles.emitting = true var timer = get_tree().create_timer(particles.lifetime, false)
get_parent().add_child(particles) timer.connect("timeout", particles, "queue_free")
var timer = get_tree().create_timer(particles.lifetime, false)
timer.connect("timeout", particles, "queue_free")