extends CharacterBody2D

    # 耐久力
    const HP = 1
    # 壊したときに出すアイテム
    const Item = preload("res://Item/item.tscn")
    # スプライト
    @onready var sprite = $AnimatedSprite2D
    # 耐久力
    var hp			: float = HP
    
    # Called when the node enters the scene tree for the first time.
    func _ready():
        pass # Replace with function body.
    
    
    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()
                # add_child()を呼び出し可能状態にする
                var callable = owner.add_child.bind(temp_node)
                # 呼び出し可能にしたadd_child()を1フレーム空けて呼び出す
                get_tree().process_frame.connect(callable, CONNECT_ONE_SHOT)
                temp_node.global_position = global_position
    
    
    func _on_animated_sprite_2d_animation_finished():
        queue_free()