diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2023-12-25 00:21:50 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2023-12-25 00:21:50 +0100 |
commit | 0bfda86c29d106df5fa3dd16d925c193b3f726c7 (patch) | |
tree | 7d248694a63c346f5e82510b50405e34f8d5afe5 /Levels | |
parent | 09794cc76678247592ceb4e8b37e1ab129356466 (diff) |
UI + HUD alignmentv2.0.0
Diffstat (limited to 'Levels')
-rw-r--r-- | Levels/Level.gd | 14 |
1 files changed, 9 insertions, 5 deletions
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): |