2D and UI Workflows

2D and UI is where most GDLink projects start — menus, HUDs, sprites, input handling, and fast prototypes. Everything here follows one shape: a listener notices something, a gate decides whether it counts, and an executor makes it happen. Wire those three and you have behavior you can see and follow.

Reading input

Input is the spark for most 2D logic — there’s one listener per source.

Keyboard — movement, actions, hotkeys. The trigger mode matters: While Held for continuous movement, On Press for one-shots like jump.

Keyboard(key=W, trigger_mode=While Held) -> AND -> Motion2D(forward)
Keyboard(key=Space, trigger_mode=On Press) -> AND -> Motion2D(jump)

Mouse — beyond clicks, it exposes screen/world position, delta, and wheel as values your graph can read directly. Feed {prefix}_world_2d straight into a Servo or Track To for top-down aiming — no helper code.

UI Click and UI Hover — for Control nodes specifically. Click drives buttons and menu navigation; Hover powers highlights and tooltips.

UI Click listener on the PlayButton through an AND gate into a UI Visibility executor that hides the MainMenu

Moving and animating

Motion2D is the workhorse for moving Node2D objects — four physics modes (Simple, Force, Velocity, Character) and three motion types (Move, Rotate, Top-Down). Character mode for platformers, Top-Down for twin-stick.

Sprite handles frame animation and texture swaps; Animation drives AnimationPlayer / AnimatedSprite2D with blending:

Property(state, Equal, idle) -> AND -> Animation(name=idle, mode=Play, loop=true)
Property(state, Equal, run)  -> AND -> Animation(name=run,  mode=Play, loop=true, blend=0.2)

Tip

For smooth colour or transparency transitions, reach for Material rather than Sprite — Sprite colour changes are set/switch, not blended.

Building UI — HUDs and menus

The GDLink UI workflow is simple: author your UI nodes in the scene ahead of time, then drive them at runtime.

Label writes text into a UI node — Set for instant readouts (score, timers), Typewrite for dialogue with BBCode and variable interpolation. A live clock is just:

Label(target=HUDClock, mode=Set, text="{_system_time.hms}")

UI Visibility shows or hides Control nodes — pause menus, tooltips, inventory panels, HUD toggles. UI Parameters and Transform2D tweak live UI properties and layout.

Putting it together — a 2D character

Keyboard(A/D, While Held)   -> AND -> Motion2D(move, Character mode)
Keyboard(Space, On Press)   -> AND -> Motion2D(jump)
Property(speed, Greater, 0) -> AND -> Animation(name=run, blend=0.2)
Label(target=HUD_Score, mode=Set, text="Score: {score}")

Input drives motion, state drives animation, and a Label keeps the HUD live — all visible in the graph, all editable without touching a code file.

Where to go next