Skip to main content

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.

Groups are the primary way to target and animate objects in Geometry Dash. Every object can belong to one or more groups, and triggers operate on groups rather than individual objects. In G.js the $group class wraps a numeric group ID and exposes every group-related trigger as a chainable method, so you never need to construct trigger dictionaries by hand. For a conceptual overview see Groups, Colors & Blocks.

Creating Groups

group(id)

Creates a $group instance from a known group ID. G.js marks this ID as in-use so it will not be allocated again by unknown_g().
const my_group = group(3);
my_group.move(0, 30, 0.5);
id
number
required
The GD group ID (1–9999).
Returns $group

unknown_g()

Allocates and returns the next free group ID. Use this whenever you need a group but do not care about its exact number.
const player_group = unknown_g();
Returns $group

new $group(a, specific?)

The underlying class constructor. Prefer group() and unknown_g() in day-to-day code; use the constructor when you need fine-grained control.
a
number
required
The group ID value.
specific
boolean
default:"true"
When true (the default), marks this ID as unavailable for future unknown_g() allocations.
$group is also a named TypeScript export for use in type annotations:
import { $group } from '@g-js-api/g.js/safe';

function moveUp(g: $group) {
  g.move(0, 50, 1);
}

Methods

call(delay?)

Calls (activates) the group, firing any spawn triggers assigned to it.
delay
number
default:"0"
Seconds to wait before the call fires.
my_group.call(0.5); // call after 0.5 s

move(x, y, duration?, easing?, easing_rate?, x_multiplier?, y_multiplier?, multiply?, silent?)

Creates a Move trigger that shifts the group by (x, y) units.
x
number
required
Distance to move along the X axis.
y
number
required
Distance to move along the Y axis.
duration
number
default:"0"
How long the movement takes, in seconds.
easing
easing
default:"NONE"
Easing curve to apply. See Easing constants.
easing_rate
number
default:"2"
Easing rate multiplier.
x_multiplier
number
default:"1"
Multiplier applied to movement on the X axis.
y_multiplier
number
default:"1"
Multiplier applied to movement on the Y axis.
multiply
boolean
default:"false"
When true, fits the movement amount into GD units (multiplying by 3).
silent
boolean
default:"false"
When true, the move trigger takes no time (instant snap).
my_group.move(0, 60, 1, EASE_IN_OUT, 2);

precise_move(x, y, duration, easing?, easing_rate?, single?)

Combines a Move trigger with a Follow trigger to achieve sub-pixel decimal movement accuracy (up to 2 decimal places). Coordinates use 10 units per grid square.
x
number
required
Units to move on X (10 = one grid square).
y
number
required
Units to move on Y (10 = one grid square).
duration
number
required
Duration of the movement in seconds.
easing
easing
default:"NONE"
Easing curve. See Easing constants.
easing_rate
number
default:"2"
Easing rate multiplier.
single
boolean
default:"false"
When true, saves groups and trigger objects if the group contains only one object.

scale(center, scale_x, scale_y, duration?, easing?, easing_rate?, x_divide?, y_divide?, move_only?, relative_scale?, relative_rot?)

Creates a Scale trigger that resizes the group around center.
center
$group
required
The group to use as the scaling pivot point.
scale_x
number
required
Scale factor on the X axis.
scale_y
number
required
Scale factor on the Y axis.
duration
number
default:"0"
Duration of the scale animation in seconds.
easing
easing
default:"NONE"
Easing curve.
easing_rate
number
default:"2"
Easing rate multiplier.
x_divide
boolean
default:"false"
When true, divides the current X scale by scale_x instead of multiplying.
y_divide
boolean
default:"false"
When true, divides the current Y scale by scale_y instead of multiplying.
move_only
boolean
default:"false"
Emulates scaling by moving child objects, without changing their actual scale values.
relative_scale
boolean
default:"false"
Bases scaling on the reference (center) object.
relative_rot
boolean
default:"false"
Rotates the X and Y axes relative to the center object’s rotation.
const pivot = unknown_g();
my_group.scale(pivot, 1.5, 1.5, 0.4, EASE_OUT);

rotate(center, degrees, duration?, easing?, easing_rate?, lock_object_rotation?)

Creates a Rotate trigger around the center group.
center
$group
required
Group to rotate around.
degrees
number
required
Degrees to rotate. Positive = clockwise.
duration
number
default:"0"
Duration in seconds.
easing
easing
default:"NONE"
Easing curve.
easing_rate
number
default:"2"
Easing rate multiplier.
lock_object_rotation
boolean
default:"false"
When true, enables “Lock Object Rotation” on the trigger so child objects do not rotate around their own axes.
my_group.rotate(pivot_group, 360, 2, EASE_IN_OUT);

follow(other, x_mod?, y_mod?, duration?)

Creates a Follow trigger that makes this group mirror the movement of other.
other
$group
required
The group to follow.
x_mod
number
default:"1"
Speed modifier on the X axis. Values below 1 slow the follow, above 1 amplify it.
y_mod
number
default:"1"
Speed modifier on the Y axis.
duration
number
default:"0"
How many seconds the follow lasts. 0 means indefinite.
camera_group.follow(player_group, 1, 0.5, 999);

follow_lerp(groupA, groupB, weight?, duration?)

Keeps the group’s position proportionally between two other groups using linear interpolation.
groupA
$group
required
First reference group.
groupB
$group
required
Second reference group.
weight
number
default:"0.5"
Interpolation weight (0 = fully at A, 1 = fully at B).
duration
number
default:"0"
Duration in seconds. 0 means indefinite.

follow_player_y(speed?, delay?, offset?, max_speed?, duration?)

Creates a Follow Player Y trigger that locks the group to the player’s vertical position.
speed
number
default:"0"
How quickly the group snaps to the player’s Y position.
delay
number
default:"0"
Seconds of delay before the group starts following.
offset
number
default:"0"
Vertical offset from the player’s Y position.
max_speed
number
default:"0"
Maximum speed at which the group can move. 0 = unlimited.
duration
number
default:"0"
How long the follow lasts. 0 = indefinite.

move_to(target, duration?, x_only?, y_only?, easing?, easing_rate?)

Creates a Move To trigger that moves the group to the position of target.
target
$group
required
The target group whose position to move to.
duration
number
default:"0"
Duration of movement in seconds.
x_only
boolean
default:"false"
Only move on the X axis.
y_only
boolean
default:"false"
Only move on the Y axis.
easing
easing
default:"NONE"
Easing curve.
easing_rate
number
default:"2"
Easing rate multiplier.

move_to_xy(x, y, duration?, easing?, easing_rate?)

Moves the group to an absolute coordinate (x, y) rather than to another group.
x
number
required
Target X coordinate.
y
number
required
Target Y coordinate.
duration
number
default:"0"
Duration in seconds.
easing
easing
default:"NONE"
Easing curve.
easing_rate
number
default:"2"
Easing rate multiplier.

alpha(opacity?, duration?)

Creates an Alpha trigger that changes the group’s opacity.
opacity
number
default:"1"
Target opacity, where 0 is fully transparent and 1 is fully opaque.
duration
number
default:"0"
Duration of the fade in seconds.
my_group.alpha(0, 0.5); // fade out over 0.5 s

lock_to_player(lock_x?, lock_y?, duration?)

Creates a Lock to Player trigger that pins the group to the player’s position.
lock_x
boolean
default:"true"
Lock to the player’s X axis.
lock_y
boolean
default:"true"
Lock to the player’s Y axis.
duration
number
default:"999"
How many seconds the lock lasts.

stop()

Creates a Stop trigger that halts all active move/rotate/follow triggers targeting this group.
my_group.stop();

pause()

Pauses active triggers on the group without removing them.

resume()

Resumes previously paused triggers on the group.

toggle_on()

Creates a Toggle trigger (on variant) that makes the group’s objects visible and active.

toggle_off()

Creates a Toggle trigger (off variant) that hides and deactivates the group’s objects.
my_group.toggle_off();
// ... later ...
my_group.toggle_on();

pulse(c, fade_in?, hold?, fade_out?, exclusive?)

Creates a Pulse trigger targeting this group using an RGB color.
c
number[]
required
RGB color array, e.g. [255, 128, 0].
fade_in
number
default:"0"
Seconds to fade into the pulse color.
hold
number
default:"0"
Seconds to hold the pulse color at full intensity.
fade_out
number
default:"0"
Seconds to fade back to the original color.
exclusive
boolean
default:"false"
When true, this pulse takes priority over simultaneous pulses on the same target.
my_group.pulse([255, 100, 50], 0.1, 0.3, 0.2);

pulse_hsv(h, s, b, s_checked?, b_checked?, fade_in?, hold?, fade_out?, exclusive?)

Creates a Pulse trigger targeting this group using HSV values instead of RGB.
h
number
required
Hue offset (-180 to 180).
s
number
required
Saturation value.
b
number
required
Brightness value.
s_checked
boolean
default:"false"
When true, the saturation value is used as an absolute value rather than an offset.
b_checked
boolean
default:"false"
When true, the brightness value is used as an absolute value rather than an offset.
fade_in
number
default:"0"
Fade-in time in seconds.
hold
number
default:"0"
Hold time in seconds.
fade_out
number
default:"0"
Fade-out time in seconds.
exclusive
boolean
default:"false"
Prioritize over simultaneous pulses.

animate(anim_id?)

Creates an Animate trigger for monsters and animated objects.
anim_id
number
default:"0"
Animation ID. You can also use the animations helper object (e.g. animations.bat.attack01) to find the correct ID without looking it up manually.
monster_group.animate(animations.bat.idle01);

remap(...mps)

Remaps group IDs inside this group to new ones. Pass pairs of [from, to] group arguments.
mps
any[]
required
Pairs of groups to remap. Each call accepts any number of [source, destination] group pairs, e.g. remap([group(1), group(2)], [group(4), group(3)]).
Returns this (chainable)
my_group.remap([group(1), group(5)], [group(2), group(6)]);

Easing constants

Pass these to any easing parameter. They are all exported from @g-js-api/g.js/safe.
ConstantDescription
NONENo easing (linear)
EASE_INEase in
EASE_OUTEase out
EASE_IN_OUTEase in and out
ELASTIC_INElastic ease in
ELASTIC_OUTElastic ease out
ELASTIC_IN_OUTElastic ease in and out
BOUNCE_INBounce ease in
BOUNCE_OUTBounce ease out
BOUNCE_IN_OUTBounce ease in and out
EXPONENTIAL_INExponential ease in
EXPONENTIAL_OUTExponential ease out
EXPONENTIAL_IN_OUTExponential ease in and out
SINE_INSine ease in
SINE_OUTSine ease out
SINE_IN_OUTSine ease in and out
BACK_INBack ease in
BACK_OUTBack ease out
BACK_IN_OUTBack ease in and out

Full example

const platform = group(1);
const pivot    = unknown_g();

// Slide platform right, then bounce it back
platform.move(150, 0, 1, EASE_OUT);
platform.move(-150, 0, 1, EASE_IN);

// Rotate a decoration around a pivot
const deco = group(2);
deco.rotate(pivot, 360, 2, SINE_IN_OUT);

// Fade out a hazard when player is near
const hazard = unknown_g();
hazard.alpha(0, 0.3);

// Pulse a group red on hit
hazard.pulse([255, 0, 0], 0.05, 0.1, 0.2);
Use unknown_g() any time you need a group for internal bookkeeping. G.js tracks all allocated IDs and will never return the same ID twice, preventing accidental group collisions.

Build docs developers (and LLMs) love