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.

Events allow trigger functions to react to in-game occurrences such as touch input, collisions, player death, and positional thresholds. The central pattern is on(someEvent(), callback)on wires the event to a group or trigger function, and the event factory configures what to listen for.

on

Registers a trigger function or group to be called whenever the given event fires.
import { on, touch, trigger_function } from 'geometry-dash-gjs';

on(touch(), trigger_function(() => {
  // runs every time the screen is touched
}));
event
GJsEvent
required
An event object returned by one of the event factory functions below.
callback
any
required
A trigger function or group to call when the event fires.

touch

Listens for a screen-touch event. Returns a GJsEvent to be passed to on.
import { on, touch, trigger_function } from 'geometry-dash-gjs';

on(touch(), trigger_function(() => {
  // fires on any touch
}));

// Dual-side only
on(touch(true), trigger_function(() => {
  // fires only on dual-side touch
}));
dual_side
boolean
default:"false"
When true, only listens to dual-side touch input.
Returns GJsEvent.

touch_end

Listens for when the screen stops being touched.
import { on, touch_end, trigger_function } from 'geometry-dash-gjs';

on(touch_end(), trigger_function(() => {
  // fires when touch is released
}));
dual_side
boolean
default:"false"
When true, only listens to dual-side touch release.
Returns GJsEvent.

collision

Fires when two collision blocks begin overlapping. Use block() to create block IDs, and pass P1/P2 to substitute the player for block a.
import { on, collision, block, trigger_function } from 'geometry-dash-gjs';

const blockA = block(1);
const blockB = block(2);

on(collision(blockA, blockB), trigger_function(() => {
  // fires when block 1 and block 2 collide
}));

// Player 1 as the first collider
on(collision(blockA, blockB, true), trigger_function(() => {
  // fires when the player enters block 1's area
}));
a
any
required
First collision block.
b
any
required
Second collision block.
P1
boolean
Use Player 1 as block a.
P2
boolean
Use Player 2 as block a.
Returns GJsEvent.

collision_exit

Fires when two collision blocks stop overlapping.
import { on, collision_exit, block, trigger_function } from 'geometry-dash-gjs';

on(collision_exit(block(1), block(2)), trigger_function(() => {
  // fires when the blocks separate
}));
a
any
required
First collision block.
b
any
required
Second collision block.
P1
boolean
Use Player 1 as block a.
P2
boolean
Use Player 2 as block a.
Returns GJsEvent.

death

Fires when the player dies.
import { on, death, trigger_function } from 'geometry-dash-gjs';

on(death(), trigger_function(() => {
  // runs on player death
}));
Returns GJsEvent.

count

Fires when a pickup item or counter reaches a specific value. Setting multi to true allows the event to fire repeatedly each time the value is hit.
import { on, count, counter, trigger_function } from 'geometry-dash-gjs';

const c = counter(0);

on(count(c.item, 5), trigger_function(() => {
  // fires when c reaches 5
}));

// Fire every time c reaches 10 (multi-trigger)
on(count(c.item, 10, true), trigger_function(() => {
  // fires each time c hits 10
}));
it
any
required
The item ID to watch (typically counter.item).
hits
number
required
The value that triggers the event.
multi
boolean
default:"false"
When true, the event can fire more than once.
Returns GJsEvent.

x_position

Fires when the player’s X position reaches the specified coordinate.
import { on, x_position, trigger_function } from 'geometry-dash-gjs';

on(x_position(300), trigger_function(() => {
  // fires when the player reaches x=300
}));
position
number
required
The X coordinate at which the event triggers.
Returns GJsEvent.

frame

Returns a GJsEvent that fires on every game tick (1/240 s). Use with on to run a trigger function every tick.
import { on, frame, trigger_function } from 'geometry-dash-gjs';

on(frame(), trigger_function(() => {
  // runs every game tick
}));
Returns GJsEvent.

render_frame

Returns a GJsEvent that fires on every render frame. Render frames are variable and depend on the player’s display frame rate setting.
import { on, render_frame, trigger_function } from 'geometry-dash-gjs';

on(render_frame(), trigger_function(() => {
  // runs every render frame
}));
Returns GJsEvent.

event

Low-level access to the GD Event trigger. Lets you listen to named events with optional extra IDs for more granular control.
import { on, event, trigger_function } from 'geometry-dash-gjs';

on(event('my_event'), trigger_function(() => {
  // fires when 'my_event' is broadcast
}));

// With extra IDs
on(event('my_event', 1, 2), trigger_function(() => {}));
ev
any
required
The event name or event object to listen to.
extra_id
number
Extra ID 1 for additional filtering.
extra_id2
number
Extra ID 2 for additional filtering.
Returns GJsEvent.

gamescene

Returns a Gamescene object that exposes the four player-input buttons as event sources, plus a hidden_group for internal use. This is the recommended way to handle jump/input events in dual-player levels.
import { gamescene, on, trigger_function } from 'geometry-dash-gjs';

const gs = gamescene();

on(gs.button_a(), trigger_function(() => {
  // Player 1 pressed jump (button A)
}));

on(gs.button_b(), trigger_function(() => {
  // Player 2 pressed jump (button B)
}));

on(gs.button_a_end(), trigger_function(() => {
  // Player 1 released jump
}));
Returns Gamescene.

Gamescene Interface

button_a
() => GJsEvent
Event fired when Player 1 presses the jump button (button A).
button_b
() => GJsEvent
Event fired when Player 2 presses the jump button (button B).
button_a_end
() => GJsEvent
Event fired when Player 1 releases button A.
button_b_end
() => GJsEvent
Event fired when Player 2 releases button B.
hidden_group
any
Internal group used by the gamescene system.

Build docs developers (and LLMs) love