Geometry Dash’s runtime behavior — movement, color changes, collision detection — is driven by three kinds of numeric IDs: groups, colors, and blocks. G.js wraps each kind in a typed class (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/g-js-api/G.js/llms.txt
Use this file to discover all available pages before exploring further.
$group, $color, $block) that carries the raw ID value and exposes every corresponding trigger as an ordinary method call, so you can drive your level’s logic in plain JavaScript without ever constructing trigger dictionaries by hand.
The Three ID Types
| Type | Class | Factory | Next-Free Factory |
|---|---|---|---|
| Group | $group | group(id) | unknown_g() |
| Color channel | $color | color(id) | unknown_c() |
| Collision block | $block | block(id) | unknown_b() |
import '@g-js-api/g.js') and the safe named API (import { group, color, block, ... } from '@g-js-api/g.js/safe').
Creating IDs
Known IDs — group(), color(), block()
Use these when you need a specific numeric ID, for example to reference a group you already placed in the GD editor.
Next-Free IDs — unknown_g(), unknown_c(), unknown_b()
Use these when you want G.js to automatically assign the next available ID. This mirrors the “Next Free” button in the GD editor and is the recommended approach for most programmatic levels.
The specific Parameter
Both factory functions accept an optional second argument specific (default true). When true, G.js marks that ID as taken and will never reuse it for an unknown_* call. Set it to false if you want to reference an ID without reserving it.
$group Methods
A $group value exposes every group-targeting trigger as a method. All methods generate the appropriate GD trigger and add it to the current context automatically.
All duration and delay parameters default to
0 unless otherwise noted.Movement
Emits a Move trigger.
x and y are in big-step GD units. Set multiply: true to convert automatically.Combines a Move trigger with a Follow trigger for sub-unit decimal precision (up to 2 decimal places).
single saves groups and objects when the group contains only one object.Move Target trigger — moves the group to the position of
target group.Moves the group to an absolute coordinate.
Follow trigger — makes the group follow
other. x_mod/y_mod scale the speed on each axis.Keeps the group’s position proportionally between
groupA and groupB.Locks the group to the player’s Y axis.
Locks the group to the player’s position. Defaults to locking both axes for 999 seconds.
Rotation and Scale
Rotate trigger.
center is a $group to rotate around.scale(center, scale_x, scale_y, duration?, easing?, easing_rate?, x_divide?, y_divide?, move_only?, relative_scale?, relative_rot?)
void
Scale trigger. Set
move_only: true to emulate scaling by moving instead of actually scaling.Visibility and Alpha
Alpha trigger — changes the group’s opacity.
Toggle On trigger.
Toggle Off trigger.
Control Flow
Spawn trigger — calls the group (optionally after a delay in seconds).
Stop trigger — stops all active triggers targeting this group.
Pauses the group.
Resumes a paused group.
Animation
Animate trigger. You can pass an animation ID directly or use the
animations.[monster].[name] constants (e.g. animations.bat.idle01).Pulse
Pulse trigger with an RGB color array.
Pulse trigger with HSV values.
Remap
Remaps multiple IDs inside the group to others, e.g.
remap([group(1), group(2)], [group(4), group(3)]).Example
$color Methods
A $color value provides methods that emit color channel triggers.
Color trigger — changes the channel to RGB value
c (an array [r, g, b]). Use the rgb() helper to build the array.Copy Color trigger — copies another color channel to this one.
hvs defaults to "0a1a1a0a0".Pulse trigger with an RGB color array.
Pulse trigger with HSV values.
Color Channel Constants
G.js exports named constants for all of GD’s built-in color channels so you never have to remember their numeric IDs:| Constant | Channel |
|---|---|
BG | Background |
GROUND | Ground |
LINE | Line |
_3DLINE | 3D Line |
OBJECT | Object |
GROUND2 | Ground 2 |
BLACK | Black |
WHITE | White |
LIGHTER | Lighter |
MIDDLEGROUND | Middleground |
MIDDLEGROUND_2 | Middleground 2 |
Example
$block Methods
A $block value provides methods for GD’s collision system.
Returns a collision block object placed at the given coordinates. Call
.add() on the result to add it to the level.Collision trigger — calls
true_id group when this block collides with b2, and false_id when it stops colliding.Example
Type Annotations
$group, $color, and $block are also exported as TypeScript types for use in type annotations:
Objects & Triggers
How to create and configure GD objects using
object(), trigger(), and obj_props.Trigger Functions
Group triggers into callable units with
trigger_function() and manage contexts.