fix crash when arrows collide with multiple things at once (fixes #50)

This commit is contained in:
Haze Weathers 2023-02-17 12:37:53 -05:00
parent 0ec9a3ec79
commit c577f0a57c
2 changed files with 13 additions and 1 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=2]
[gd_scene load_steps=19 format=2]
[ext_resource path="res://objects/player/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://tilesets/t_cave.tres" type="TileSet" id=2]
@ -16,6 +16,7 @@
[ext_resource path="res://objects/environment/falling_block/falling_block.tscn" type="PackedScene" id=14]
[ext_resource path="res://objects/environment/moving_platform/moving_platform.tscn" type="PackedScene" id=15]
[ext_resource path="res://objects/respawn_point.tscn" type="PackedScene" id=16]
[ext_resource path="res://objects/player/arrow_projectile.tscn" type="PackedScene" id=17]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 20 )
@ -117,3 +118,10 @@ position = Vector2( 88, 160 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="RespawnPoint"]
position = Vector2( 0, -4 )
shape = SubResource( 1 )
[node name="ArrowProjectile" parent="." instance=ExtResource( 17 )]
position = Vector2( 128, 128 )
[node name="ArrowProjectile2" parent="." instance=ExtResource( 17 )]
position = Vector2( 198, 130 )
speed = 0.0

View file

@ -64,6 +64,10 @@ func _exit_tree():
get_tree().create_timer(particles.lifetime, false).connect("timeout", particles, "queue_free")
func _make_sparks():
# return if this has already happened to avoid crash
if is_queued_for_deletion():
return
var particles = $SparkParticles
remove_child(particles)
particles.global_position = global_position + particles.position * scale.x