blob: a78a81d8925c2cbecfa32b517724daecd7250e48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
extends Node2D
export var maxhealth = 3
export var offset = 40
var h: PackedScene = preload("res://components/healthbar/heart.tscn")
var hearts: Array = []
# Called when the node enters the scene tree for the first time.
func _ready():
for i in maxhealth:
var heart = h.instance()
hearts.append(heart)
heart.position = Vector2(i * offset, 0)
heart.scale = Vector2(3,3)
add_child(heart)
func _process(delta):
pass
func set_health(health: int=maxhealth):
for i in maxhealth:
hearts[i].set_filled(i < health)
|