extends CharacterBody2D
const HP = 1
const Item = preload("res://Item/item.tscn")
@onready var sprite = $AnimatedSprite2D
var hp : float = HP
func _ready():
pass
func damage(_power : float):
hp -= _power
if hp <= 0:
sprite.play("Break")
collision_layer = 0x00
collision_mask = 0b00000001
if Item != null:
var temp_node = Item.instantiate()
var callable = owner.add_child.bind(temp_node)
get_tree().process_frame.connect(callable, CONNECT_ONE_SHOT)
temp_node.global_position = global_position
func _on_animated_sprite_2d_animation_finished():
queue_free()