Player health UI is bound to singleton

This commit is contained in:
karl committed 2020-02-01 12:22:18 +01:00
1 parent c8acaf0988
commit a773e5900d
6 files changed
+65 -6

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
extends ProgressBar
export(int) var player_id
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
InGameState.connect("player_health_updated", self, "_on_player_health_updated")
max_value = InGameState.max_health
func _on_player_health_updated(updated_id, updated_health):
if player_id == updated_id:
value = updated_health
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta: float) -> void:
# pass
+7 -2
View File
@@ -1,4 +1,6 @@
[gd_scene format=2]
[gd_scene load_steps=2 format=2]
[ext_resource path="res://UI/PlayerHealth.gd" type="Script" id=1]
[node name="UI" type="Control"]
anchor_right = 1.0
@@ -33,13 +35,14 @@ __meta__ = {
[node name="HSplitContainer" type="HSplitContainer" parent="MarginContainer/PlayerHealthController/VSplitContainer"]
margin_right = 984.0
margin_bottom = 546.0
margin_bottom = 560.0
split_offset = 492
dragger_visibility = 1
[node name="Player1Health" type="ProgressBar" parent="MarginContainer/PlayerHealthController/VSplitContainer/HSplitContainer"]
margin_right = 496.0
margin_bottom = 14.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
@@ -48,11 +51,13 @@ __meta__ = {
margin_left = 508.0
margin_right = 984.0
margin_bottom = 14.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HSplitContainer2" type="HSplitContainer" parent="MarginContainer/PlayerHealthController/VSplitContainer"]
visible = false
margin_top = 546.0
margin_right = 984.0
margin_bottom = 560.0