G.js provides a keyframe animation system that wraps GD’s native keyframe triggers, letting you define a sequence of position, rotation, and scale states and play them back on any group. This is distinct from GD’s built-in animation IDs (which play pre-made monster animations) — the keyframe system gives you full control over each step of the animation timeline.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.
How the Keyframe System Works
Keyframe animations work in two steps:- Define keyframes — each keyframe is a snapshot of position (
x,y),rotation, and scale (scale_x,scale_y) at a given point in time. - Animate a target — the
animate()call ties a group of keyframes to a target object group, playing them in sequence.
GJsObject values, meaning you must call .add() on each keyframe and on the animate trigger to include them in your level.
keyframe_system()
keyframe_system() takes no arguments and returns an object with two methods: keyframe() and animate(). Call it once and reuse the returned object for all keyframes belonging to the same animation sequence.
anim.keyframe()
GJsObject — you must call .add() on it.
| Parameter | Type | Default | Description |
|---|---|---|---|
x | number | — | Target X position |
y | number | — | Target Y position |
rotation | number | — | Target rotation in degrees |
scale_x | number | — | Target X scale |
scale_y | number | — | Target Y scale |
duration | number | 0 | Time in seconds to reach this state from the previous keyframe |
easing | number | NONE | Easing curve constant (see table below) |
anim.animate()
GJsObject — you must call .add() on it.
| Parameter | Type | Default | Description |
|---|---|---|---|
target | group | — | The group to animate |
keyframes | any | — | The keyframe sequence to play back |
duration | number | 0 | Overall animation duration override |
easing | number | NONE | Global easing override |
Easing Constants
G.js exposes all of GD’s built-in easing curves as named constants. Import them from the global scope or from@g-js-api/g.js/safe.
| Constant | Description |
|---|---|
NONE | No easing (linear) |
EASE_IN | Ease in |
EASE_OUT | Ease out |
EASE_IN_OUT | Ease in and out |
ELASTIC_IN | Elastic ease in |
ELASTIC_OUT | Elastic ease out |
ELASTIC_IN_OUT | Elastic ease in and out |
BOUNCE_IN | Bounce ease in |
BOUNCE_OUT | Bounce ease out |
BOUNCE_IN_OUT | Bounce ease in and out |
BACK_IN | Back ease in (slight overshoot) |
BACK_OUT | Back ease out |
BACK_IN_OUT | Back ease in and out |
SINE_IN | Sine ease in |
SINE_OUT | Sine ease out |
SINE_IN_OUT | Sine ease in and out |
EXPONENTIAL_IN | Exponential ease in |
EXPONENTIAL_OUT | Exponential ease out |
EXPONENTIAL_IN_OUT | Exponential ease in and out |
Creating a Bounce Animation
The following example animates a platform group so it bounces upward and back down with an elastic ease:Define keyframes
Each keyframe describes where the group should be at that point in the sequence. Call
.add() on every keyframe.Full Bounce Animation Script
GD Animation IDs ($group.animate())
This is a different feature from the keyframe system above.
$group.animate(anim_id?) triggers one of GD’s built-in monster/enemy animation sequences on an object group — it does not use the keyframe_system() API..animate() method on a group reference, passing one of the IDs from the animations constant object.
Available Animation IDs
Theanimations object contains IDs grouped by creature type:
animations.big_beast
| Key | Description |
|---|---|
bite | Bite attack |
attack01 | Attack sequence 1 |
attack01_end | End of attack sequence 1 |
idle01 | Idle loop 1 |
animations.bat
| Key | Description |
|---|---|
idle01 | Idle loop 1 |
idle02 | Idle loop 2 |
idle03 | Idle loop 3 |
attack01 | Attack sequence 1 |
attack02 | Attack sequence 2 |
attack02_end | End of attack sequence 2 |
sleep | Sleep start |
sleep_loop | Sleep loop |
sleep_end | Wake from sleep |
attack02_loop | Attack loop 2 |
animations.spikeball
| Key | Description |
|---|---|
idle01 | Idle loop 1 |
idle02 | Idle loop 2 |
toAttack01 | Transition to attack 1 |
attack01 | Attack sequence 1 |
attack02 | Attack sequence 2 |
toAttack03 | Transition to attack 3 |
attack03 | Attack sequence 3 |
idle03 | Idle loop 3 |
fromAttack03 | Return from attack 3 |
Example — Trigger a Bat Attack
Particles & Shaders
Create particle systems and apply GD 2.2 post-processing shaders.
Camera & Visual
Camera offsets, rotation, zoom, and free-mode controls.
Keyframes API Reference
Full API reference for the keyframe system.
Events
Respond to touch, collision, death, and other GD events.