gamedev-skills/awesome-gamedev-agent-skills

godot-ui-control

Build Godot 4.7 user interfaces with Control nodes: anchors and offsets for responsive layout, Container nodes (VBox/HBox/Grid/Margin) for automatic arrangement, Theme resources for consistent styling, and keyboard/gamepad focus navigation.

Vedi sorgente

Come usare

  1. Copia il comando e controlla il pacchetto prima di installarlo nel tuo ambiente agente.
  2. Controlla strumenti, credenziali e ambienti richiesti nel documento originale.
  3. Descrivi input e risultato desiderato; confronta l’output con le fonti.
npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill godot-ui-control

Prima di iniziare

  • L’installazione non include abbonamenti, quote API o accesso ai file.
  • Stelle e installazioni indicano attività, non un test indipendente di qualità o sicurezza.
Documento Skill originale

Contenuto dal repository con titoli, esempi, codice, tabelle, link e immagini preservati.

Godot UI / Control nodes (4.x)

Lay out responsive UI with Control anchors and Container nodes, style it with a Theme, and make it navigable by keyboard and gamepad. Targets Godot 4.7.

When to use

  • Use when building HUDs, menus, inventories, dialog boxes, or settings screens with

Control-derived nodes; arranging UI that adapts to window size; theming; or wiring focus navigation for controller/keyboard.

When not to use:* in-world 2D nodes (Node2D/sprites) → godot-nodes-scenes; animating UI transitions → godot-animation (Tween); genre UIs like card hands → card-game/visual-novel. For full input rebinding → input-systems.

Core workflow

  1. Use `Control` nodes for UI, not Node2D. Controls have a rect (position + size),

anchors, and participate in focus/theming.

  1. Anchor for responsiveness. Anchors are fractions (0–1) of the parent rect that the

Control's edges stick to. Use the editor's Layout presets (Top-Left, Full Rect, Center, etc.) instead of hand-placing pixels.

  1. Let Containers position children. Put children in a VBoxContainer,

HBoxContainer, GridContainer, MarginContainer, etc. — the container sets their position/size; you control flow with size_flags. Don't set child anchors inside a container (it overrides them).

  1. Style with a `Theme`. Assign a Theme resource on a top Control; children inherit

it. Override per-node with theme overrides only when necessary.

  1. Wire focus so gamepad/keyboard can move between buttons; set a default focused

control and define neighbors or rely on auto-neighbor.

  1. Connect signals (pressed, toggled, text_submitted, value_changed).

Patterns

1. Responsive layout with anchors (code form)

gdscript
extends Control

func _ready() -> void:
    # Stretch this panel to fill its parent (equivalent to the "Full Rect" preset).
    anchors_preset = Control.PRESET_FULL_RECT
    # Or set anchors manually: all four edges at the parent's far corners.
    # anchor_left = 0; anchor_top = 0; anchor_right = 1; anchor_bottom = 1

2. A menu built from containers + button signals

gdscript
extends VBoxContainer    # children stack vertically, auto-sized

func _ready() -> void:
    for child in get_children():
        if child is Button:
            child.pressed.connect(_on_button_pressed.bind(child.name))
    # Give the first button focus so a gamepad can navigate immediately.
    if get_child_count() > 0:
        (get_child(0) as Control).grab_focus()

func _on_button_pressed(which: StringName) -> void:
    match which:
        "PlayButton":  get_tree().change_scene_to_file("res://game.tscn")
        "QuitButton":  get_tree().quit()

3. Size flags: make one child expand to fill leftover space

gdscript
# In a HBoxContainer: a label on the left, a spacer that eats remaining width.
func _ready() -> void:
    $Label.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
    $Spacer.size_flags_horizontal = Control.SIZE_EXPAND_FILL   # grows to fill

4. Theme override for one node (without a full Theme resource)

gdscript
func _ready() -> void:
    # Per-node overrides: use add_theme_* (type-specific setters).
    $Title.add_theme_font_size_override("font_size", 32)
    $Title.add_theme_color_override("font_color", Color.GOLD)
    $Panel.add_theme_stylebox_override("panel", preload("res://ui/panel.stylebox.tres"))

Pitfalls

  • Mixing manual position with Containers. A child of a Container cannot set its own

position/anchors — the container owns layout. To free-place, take the node out of the container or use a plain Control/PanelContainer wrapper.

  • Anchors vs offsets. Anchors are fractions of the parent; offsets are pixel deltas

from the anchored point. Set anchors via presets, then nudge with offsets. Setting only position while anchors are at 0 makes UI not scale with the window.

  • `Node2D` for UI. Buttons/labels parented under a Node2D won't theme or take focus

correctly. Keep UI under a CanvasLayer/Control subtree.

  • Focus lost on gamepad. If nothing is focused, directional input does nothing. Call

grab_focus() on an initial control and ensure focus_mode is not FOCUS_NONE.

  • Theme vs theme override. A Theme resource styles a whole subtree; add_theme_*

overrides one node. Overusing per-node overrides defeats centralized theming.

  • `rect_ properties are renamed.** Godot 3's rectsize`/`rectposition/rectminsize`

are now size/position/custom_minimum_size in 4.x.

  • `mouse_filter` on a full-rect Control can swallow clicks meant for nodes beneath it;

set MOUSE_FILTER_IGNORE on purely decorative panels.

References

  • For the anchor/offset math, every Container type, building/extending Theme and StyleBox

resources, focus neighbor wiring, and CanvasLayer for HUDs, read references/layout-and-theming.md.

Related skills

  • game-ui-ux — cross-engine UI/UX: responsive scaling, safe areas, focus navigation, screen flow.
  • godot-animation — Tween-based UI transitions and juicing.
  • godot-signals-groups — connecting UI events to game logic.
  • input-systems — rebindable input and multi-device focus.
  • card-game / visual-novel — UI-heavy genre templates.

Correlati per attività

dallo stesso repository

Altri Skills

Tutti gli Skills
gamedev-skills
Community

game-feel

Add "juice" and game feel that makes actions satisfying — screen shake, hit-stop/freeze frames, tweened/eased motion, squash & stretch, knockback, and layered audio-visual feedback — as engine-neutral techniques that pair with the detected engine's tween, particle, and camera APIs. Use when the user mentions game feel, juice, "make it feel good/punchy", screen shake, hit stop, screen freeze, easing, squash and stretch, impact frames, or feedback/polish on hits, jumps, pickups, and deaths.

installazioni
16
GitHub Stars
4,3K
Aggiornato
24 ott
gamedev-skills
Community

audio-design

Implement game audio practice — bus/mixer architecture and gain in decibels, ducking (sidechain), adaptive/dynamic music via layering and re-sequencing, SFX variation, and beat synchronization. Engine-neutral. Use when the user mentions audio mixing, audio buses, adaptive/dynamic music, ducking, SFX variation, music layers, or syncing gameplay to the beat.

installazioni
13
GitHub Stars
4,3K
Aggiornato
24 ott
gamedev-skills
Community

performance-optimization

Find and fix game performance problems methodically — measure with the engine profiler first, reason about the frame-time budget, locate the CPU-vs-GPU bottleneck, then apply the right fix: object pooling, draw-call batching, fewer allocations/GC spikes, and asset budgets. Engine- neutral method that pairs with each engine's profiler. Use when the user mentions performance, optimize, low/dropping FPS, frame drops, stutter, lag, profiler, frame budget, draw calls, batching, garbage collection/GC

installazioni
13
GitHub Stars
4,3K
Aggiornato
24 ott
gamedev-skills
Community

shader-programming

Write game shaders from cross-engine fundamentals — the vertex→fragment pipeline, coordinate spaces, UV math, and common 2D/3D effects (tint, UV scroll, dissolve, outline, fresnel rim, vignette) in GLSL with HLSL equivalents. Use when the user mentions shaders, fragment/pixel shader, vertex shader, UV, GLSL, HLSL, or effects like dissolve, outline, or rim light.

installazioni
13
GitHub Stars
4,3K
Aggiornato
24 ott