homework
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
extends Area2D
|
||||
var HP = 10
|
||||
@onready var animated_sprite = $AnimatedSprite2D
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
add_to_group("block")
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group("bullet"):
|
||||
animated_sprite.play("Hitside.block")
|
||||
HP -= 10
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
animated_sprite.play("Idle.block")
|
||||
if HP <= 0:
|
||||
get_parent().queue_free()
|
||||
else:
|
||||
animated_sprite.play("Idle.block")
|
||||
Reference in New Issue
Block a user