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.

Every visible thing and every interaction in a Geometry Dash level is an object. G.js represents objects as plain dictionaries keyed by the obj_props property name constants, and exposes two factory functions — object() for static or decorative objects and trigger() for game-logic triggers. Both return a GJsObject that you can chain property setters on before calling .add() to place the object into the level.

object(dict)

Creates a GD level object from a property dictionary and returns a chainable GJsObject.
object({
  [obj_props.OBJ_ID]: 1,
  [obj_props.X]: 75,
  [obj_props.Y]: 105,
}).add();
dict
Dictionary
required
A plain object whose keys are obj_props constants (or their raw numeric equivalents) and whose values are the corresponding property values.
Returns GJsObject

trigger(dict)

Creates a GD trigger object. Functionally identical to object() but semantically marks the result as a trigger, which affects how G.js positions it in the level when auto-positioning is enabled.
trigger({
  [obj_props.OBJ_ID]: 901,  // Color trigger
  [obj_props.GROUPS]: group(5),
}).add();
dict
Dictionary
required
Property dictionary. The same obj_props keys apply as for object().
Returns GJsObject

GJsObject

The interface returned by both object() and trigger().
type
'object'
Always 'object'. Can be used to identify G.js object values at runtime.
obj_props
Dictionary
The raw property dictionary passed to the factory function, including any properties added via .with().

.with(prop, value)

Returns a new GJsObject with prop set to value. Chainable — call as many times as needed before .add().
'Score: 0'
  .to_obj()
  .with(obj_props.X, 45)
  .with(obj_props.Y, 45)
  .with(obj_props.GROUPS, my_group)
  .add();
prop
string | number
required
The property to set. Use an obj_props constant for readability.
value
any
required
The value to assign to the property.
Returns GJsObject

.add()

Places the object into the current level context. Must be called when you are done setting properties. Returns void

String .to_obj()

G.js extends the native String prototype with a .to_obj() helper that converts a string value into a GD text object. The resulting GJsObject can be chained with .with() and finished with .add() exactly like any other object.
'Hello, World!'
  .to_obj()
  .with(obj_props.X, 150)
  .with(obj_props.Y, 225)
  .add();

obj_props

The obj_props dictionary maps human-readable property names to their GD numeric IDs. Always prefer these constants over raw numbers for maintainability.
The full list of properties is also documented at /api/obj-props.
Commonly used keys:
ConstantDescription
OBJ_IDGeometry Dash object/trigger ID
XX position
YY position
GROUPSGroup(s) assigned to the object
ROTATIONRotation in degrees
COLORPrimary color channel
COLOR_2Secondary color channel
Z_LAYERZ layer (rendering order layer)
Z_ORDERZ order within the layer
SCALINGObject scale
OPACITYObject opacity (0–1)
TEXTText content (text objects)
SPAWN_TRIGGEREDWhether the trigger is spawn-triggered
object({
  [obj_props.OBJ_ID]: 211,
  [obj_props.X]: 300,
  [obj_props.Y]: 105,
  [obj_props.ROTATION]: 45,
  [obj_props.SCALING]: 1.5,
  [obj_props.COLOR]: color(3),
  [obj_props.Z_LAYER]: 1,
}).add();

obj_ids

obj_ids is a dictionary of well-known GD object IDs indexed by descriptive name. Use it when you know the conceptual object you want but do not want to hard-code a magic number.
object({
  [obj_props.OBJ_ID]: obj_ids.spike,
  [obj_props.X]: 450,
  [obj_props.Y]: 105,
}).add();

levelstring_to_obj(string)

Parses a raw GD levelstring and returns an array of property dictionaries. Type conversions are not performed automatically — all values remain strings as they appear in the levelstring.
const objects = levelstring_to_obj(myLevelString);
objects.forEach((props) => {
  $.print(props[obj_props.OBJ_ID]);
});
string
string
required
A valid GD levelstring.
Returns Dictionary[]

obj_to_levelstring(object)

Converts a single property dictionary (or GJsObject) back into a GD levelstring fragment.
const ls = obj_to_levelstring({
  [obj_props.OBJ_ID]: 1,
  [obj_props.X]: 75,
  [obj_props.Y]: 105,
});
$.print(ls); // "1,1,2,75,3,105,"
object
Dictionary
required
The property dictionary to serialise.
Returns string

Code examples

// Place a single block at position (75, 105)
object({
  [obj_props.OBJ_ID]: 1,
  [obj_props.X]: 75,
  [obj_props.Y]: 105,
}).add();
Prefer object() over trigger() for decorative objects and scenery. G.js uses the distinction to decide whether to auto-position an item off-screen during trigger layout.
Always call .add() at the end of a chain. Objects are not placed in the level until .add() is called — a floating chain without .add() silently does nothing.

Build docs developers (and LLMs) love