spark particles when an arrow collides with tiles or is blocked
This commit is contained in:
parent
7abd3fbb42
commit
30d7e84a46
2 changed files with 43 additions and 1 deletions
|
@ -35,6 +35,7 @@ func _exit_tree():
|
|||
#Wall Collision
|
||||
func _on_Hitbox_body_entered(body):
|
||||
if body is TileMap or body is StaticBody2D:
|
||||
_make_sparks()
|
||||
queue_free()
|
||||
|
||||
# kill entity if in target group
|
||||
|
@ -46,6 +47,7 @@ func _on_Hitbox_area_entered(area):
|
|||
if area.is_in_group("blocks_arrow"):
|
||||
var pos = target.global_position
|
||||
Game.instance_node(Game.block_text, pos.x, pos.y, target.get_parent())
|
||||
_make_sparks()
|
||||
else:
|
||||
# kill targeted node
|
||||
target.die()
|
||||
|
@ -53,3 +55,12 @@ func _on_Hitbox_area_entered(area):
|
|||
if target_group == "enemy_hitbox":
|
||||
Game.arrows = max(0, Game.arrows - 1) # clamp arrows above 0
|
||||
queue_free()
|
||||
|
||||
func _make_sparks():
|
||||
var particles = $SparkParticles
|
||||
remove_child(particles)
|
||||
particles.global_position = global_position + particles.position * scale.x
|
||||
particles.emitting = true
|
||||
get_parent().add_child(particles)
|
||||
var timer = get_tree().create_timer(particles.lifetime, false)
|
||||
timer.connect("timeout", particles, "queue_free")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue