feat: add the ui display for the user hp; connect it to the scene manager;
This commit is contained in:
@@ -8,7 +8,7 @@ class_name Player
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
update_scrolls()
|
||||
print("HP: ", SceneManager.player_hp)
|
||||
%HealthBar.play("3_hp")
|
||||
var damage: float = 2
|
||||
if SceneManager.player_next_scene_spawn_pos != Vector2(0, 0):
|
||||
position = SceneManager.player_next_scene_spawn_pos
|
||||
@@ -64,11 +64,10 @@ func _on_area_2d_body_exited(body: Node2D) -> void:
|
||||
|
||||
func _on_hit_box_area_2d_body_entered(body: Node2D) -> void:
|
||||
SceneManager.player_hp -= 1
|
||||
print("HP: ", SceneManager.player_hp)
|
||||
%HealthBar.play(str(SceneManager.player_hp) + "_hp")
|
||||
if SceneManager.player_hp <= 0:
|
||||
die()
|
||||
|
||||
func die():
|
||||
print("DED")
|
||||
get_tree().call_deferred("reload_current_scene")
|
||||
SceneManager.player_hp = 3
|
||||
|
||||
Reference in New Issue
Block a user