From 0bfda86c29d106df5fa3dd16d925c193b3f726c7 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Mon, 25 Dec 2023 00:21:50 +0100 Subject: UI + HUD alignment --- Levels/Level.gd | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Levels') diff --git a/Levels/Level.gd b/Levels/Level.gd index d7ea0c9..0706b0b 100644 --- a/Levels/Level.gd +++ b/Levels/Level.gd @@ -12,6 +12,7 @@ var CancelButton = preload("res://UI/HUD/CancelButton.tscn").instantiate() func _ready(): self.set_hud() + get_tree().get_root().size_changed.connect(Callable(self, 'resize_hud')) var character = load("res://Characters/" + Network.player.character + ".tscn").instantiate() self.set_player(character) @@ -28,17 +29,20 @@ func _input(event): func set_hud(): + self.HUD.add_child(self.LabelTimer) + self.HUD.add_child(self.LevelMap) + self.HUD.add_child(self.CancelButton) + self.add_child(self.HUD) + + self.resize_hud() + +func resize_hud(): self.LabelTimer.position.x = 3 self.LevelMap.position.x = get_viewport_rect().end.x - self.LevelMap.size.x self.CancelButton.position.x = get_viewport_rect().end.x - self.CancelButton.size.x self.CancelButton.position.y = get_viewport_rect().end.y - self.CancelButton.size.y - - self.HUD.add_child(self.LabelTimer) - self.HUD.add_child(self.LevelMap) - self.HUD.add_child(self.CancelButton) - self.add_child(self.HUD) func set_player(character: CharacterBody2D): -- cgit v1.2.3