Fix: Drag-Icon Groesse nach add_child setzen damit Godot sie nicht ueberschreibt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Andre 2026-03-19 23:08:39 +01:00
parent 97848930e1
commit 341cc491fc

View file

@ -78,8 +78,6 @@ func _start_drag(skill_id: String, icon_path: String):
var tex = load(icon_path) var tex = load(icon_path)
drag_icon = TextureRect.new() drag_icon = TextureRect.new()
drag_icon.texture = tex drag_icon.texture = tex
drag_icon.custom_minimum_size = Vector2(48, 48)
drag_icon.size = Vector2(48, 48)
drag_icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE drag_icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
drag_icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED drag_icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
drag_icon.mouse_filter = Control.MOUSE_FILTER_IGNORE drag_icon.mouse_filter = Control.MOUSE_FILTER_IGNORE
@ -88,7 +86,10 @@ func _start_drag(skill_id: String, icon_path: String):
drag_layer.layer = 200 drag_layer.layer = 200
drag_layer.add_child(drag_icon) drag_layer.add_child(drag_icon)
get_tree().root.add_child(drag_layer) get_tree().root.add_child(drag_layer)
drag_icon.position = get_viewport().get_mouse_position() - Vector2(20, 20) # Größe erst nach add_child setzen, sonst überschreibt Godot sie
drag_icon.custom_minimum_size = Vector2(48, 48)
drag_icon.size = Vector2(48, 48)
drag_icon.position = get_viewport().get_mouse_position() - Vector2(24, 24)
if player and player.hud: if player and player.hud:
player.hud.set_drag_active(true) player.hud.set_drag_active(true)