2D nodes are the visual and spatial building blocks of a Fraxel scene. Every 2D node extendsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sanchedev/fraxel/llms.txt
Use this file to discover all available pages before exploring further.
Node2D, which adds a position property (Vector2) and both local and global position helpers (position for local space, globalPosition for world space). They compose hierarchically — translating a parent node moves all of its children with it. For a conceptual overview see the Nodes guide.
Base: Node2D
All 2D nodes inherit these shared props and properties fromNode2D (which itself extends Node).
Shared props (all 2D nodes)
Local position of the node in its parent’s coordinate space. Accepts a
[x, y] tuple, { x, y } object, or a single number (square). Defaults to Vector2.ZERO.Optional identifier for this node. Used with
child() to find descendants by path. Must match [a-zA-Z][a-zA-Z0-9-_]* when a string.Drawing order relative to siblings. Higher values render on top. Defaults to
0.Multiplier applied to
delta for this node and all its children. Use 0.5 for half-speed, 2 for double-speed. Defaults to 1.Optional script to attach to this node for external logic encapsulation.
Shared instance properties
| Property | Type | Description |
|---|---|---|
position | Vector2 | Local position. Mutable. |
globalPosition | Vector2 | World-space position. Readable and settable — the setter computes the required local offset. |
parent | Node | undefined | The parent node, if any. |
children | Node[] | Direct child nodes. |
isStarted | boolean | true once the node has been started. |
isDestroyed | boolean | true once destroy() has been called. |
Shared events (all nodes)
| Event | Callback | Description |
|---|---|---|
started | () => void | Fires once when the node finishes its start lifecycle. |
updated | (delta: number) => void | Fires every frame during the update cycle. delta is seconds since last frame. |
drawed | (delta: number) => void | Fires every frame during the draw cycle. |
destroyed | () => void | Fires when the node is destroyed. |
Shared methods (all nodes)
| Method | Signature | Description |
|---|---|---|
addChild | (...nodes: Node[]) => void | Adds child nodes; starts them immediately if the parent is already started. |
removeChild | (node: Node) => void | Removes a direct child. |
child | ({ path: (string | symbol)[], type: T }) => NodeInstances[T] | Finds a descendant by id path and asserts type. Throws if not found. |
destroy | () => void | Destroys the node and all its children, emitting destroyed. |
cleanEvents | () => void | Removes all event listeners. Called automatically on destroy. |
Nodes
Transform — <transform>
Transform — <transform>
Class:
Transform · Enum: PrimaryNode.Transform · JSX tag: <transform>Transform is a positioning container. It has no visual representation of its own — its sole purpose is to apply a coordinate offset to everything nested inside it. All children are drawn in the transform’s local space, so moving the transform moves all its children together.Props
Local position of the transform. Moves all children. Defaults to
Vector2.ZERO.Node identifier for
child() lookups.Z-order for rendering. Higher values render on top.
Speed multiplier applied to this node and all children.
Child nodes nested inside this transform.
Notes
Transformis the idiomatic way to group multiple child nodes that share a world position (e.g. a sprite + collider + rigid body for a single game object).- For a purely logical grouping without spatial positioning, use
<group>instead.
Sprite — <sprite>
Sprite — <sprite>
Class: Visual filter props — all reactive, all optional:
Sprite · Enum: PrimaryNode.Sprite · JSX tag: <sprite>Sprite renders a texture loaded with loadTexture(). It supports sprite sheet atlases (via margin and sourceSize), independent display scaling, horizontal/vertical flipping, and a full set of canvas-based visual filters.Props
The symbol returned by
loadTexture(). The texture must be loaded before the node starts.Local position of the sprite.
Pixel offset within the source texture. Used to select a frame from a sprite sheet.
Region of the texture to sample. Defaults to the full texture size.
Rendered size on screen. Defaults to
sourceSize.Mirror the sprite horizontally. Defaults to
false.Mirror the sprite vertically. Defaults to
false.Brightness multiplier.
0 = black, 1 = unchanged, 2 = fully white. Default 1.Grayscale amount.
0 = full color, 1 = fully desaturated. Default 0.RGBA tint
[r, g, b, a] where each channel is 0–1. Applied via multiply composite operation. Default [1, 1, 1, 1] (no tint).Contrast multiplier.
0 = flat grey, 1 = unchanged, 2 = double contrast. Default 1.Saturation multiplier.
0 = desaturated, 1 = unchanged, 2 = double saturation. Default 1.Hue rotation in degrees.
0 = unchanged, 360 = full rotation. Default 0.Color inversion amount.
0 = normal, 1 = fully inverted. Default 0.Alpha transparency.
0 = invisible, 1 = fully opaque. Default 1.Events
| Event | Callback | Description |
|---|---|---|
started | () => void | Fires when the node is started and the texture is loaded. |
updated | (delta: number) => void | Fires every frame. Use this to update position or filter values. |
destroyed | () => void | Fires when the sprite is destroyed. |
Methods
| Method | Signature | Description |
|---|---|---|
getTexture | () => Texture | undefined | Returns the currently loaded Texture object, or undefined if none is set. |
Instance properties
| Property | Type | Description |
|---|---|---|
textureId | symbol | undefined | Get/set the texture symbol. Setting updates the displayed texture immediately. |
brightness | number | Get/set the brightness filter. |
grayscale | number | Get/set the grayscale filter. |
modulate | Color | Get/set the RGBA tint. |
contrast | number | Get/set the contrast filter. |
saturate | number | Get/set the saturation filter. |
hueRotate | number | Get/set the hue rotation in degrees. |
invert | number | Get/set the inversion filter. |
opacity | number | Get/set the opacity filter. |
Rectangle — <rectangle>
Rectangle — <rectangle>
Class:
Rectangle · Enum: PrimaryNode.Rectangle · JSX tag: <rectangle>Rectangle renders a filled and optionally stroked rectangle using the canvas 2D API. All color props accept RGBA tuples with channels in the 0–1 range. Supports reactive props for dynamic UI elements like health bars, progress indicators, or debug overlays.Props
Dimensions of the rectangle
[width, height]. Required — there is no default size.Local position of the rectangle’s top-left corner. Defaults to
Vector2.ZERO.RGBA fill color
[r, g, b, a] with channels in 0–1. Defaults to [1, 1, 1, 1] (opaque white).RGBA border color. If omitted, no border is drawn.
Border width in pixels. Only used if
strokeColor is set. Defaults to 1.Events
Inherits all shared Node2D events:started, updated, drawed, destroyed.Instance properties
| Property | Type | Description |
|---|---|---|
size | Vector2 | Current dimensions. |
fillColor | Color | Current fill RGBA. |
strokeColor | Color | undefined | Current stroke RGBA, or undefined. |
strokeWidth | number | Current border width. |
Text — <text>
Text — <text>
Class:
Text · Enum: PrimaryNode.Text · JSX tag: <text>Text renders a string on the canvas using ctx.fillText(). The text prop is reactive — pass a SignalGetter<string> to automatically re-render whenever the underlying signal changes. Style is controlled via a partial TextStyle object; unset fields fall back to TextStyle.DEFAULT.Props
The string to render. Pass a
SignalGetter<string> (i.e. () => string) for reactive updates.Local position of the text’s top-left baseline. Defaults to
Vector2.ZERO.Partial style overrides. Unset fields use
TextStyle.DEFAULT values. See the table below.TextStyle fields
| Field | Type | Default | Description |
|---|---|---|---|
foregroundColor | string | '#000000' | CSS color string for the text fill. |
fontSize | number | 16 | Font size in pixels. |
fontFamily | string | 'sans-serif' | CSS font family name. |
fontWeight | FontWeight | FontWeight.Normal | FontWeight.Normal or FontWeight.Bold. |
textAlign | TextAlign | TextAlign.Start | TextAlign.Start, TextAlign.Center, or TextAlign.End. |
Events
Inherits all shared Node2D events:started, updated, drawed, destroyed.Instance properties
| Property | Type | Description |
|---|---|---|
text | string | The current rendered string. |
Collider — <collider>
Collider — <collider>
Class:
Collider · Enum: PrimaryNode.Collider · JSX tag: <collider>Collider registers a collision shape with the engine’s CollisionSystem. It fires events when another collider begins, continues, or stops overlapping with it. Shapes are created via the shapes helper (shapes.rectangle(w, h) or shapes.circle(r)). Groups and collidesWith arrays control which objects interact.For full collision documentation see the Collision guide.Props
The collision shape. Use
shapes.rectangle(width, height) or shapes.circle(radius) from the fraxel package.Labels that identify this collider. Other colliders whose
collidesWith includes one of these strings will detect this collider.Groups that this collider can collide with. Collisions only fire if both colliders mutually match each other’s groups.
Local position offset of the collision shape relative to the node’s parent.
Events
| Event | useEvent name | Callback | Description |
|---|---|---|---|
colliderEntered | 'colliderEntered' | (collider: Collider) => void | Fires once when overlap begins with another collider. |
collided | 'collided' | (collider: Collider) => void | Fires every frame while two colliders overlap. |
colliderExited | 'colliderExited' | (collider: Collider) => void | Fires once when overlap ends. |
Instance properties
| Property | Type | Description |
|---|---|---|
shape | Shape | The collision shape (read-only). |
group | Set<string> | Groups this collider belongs to (read-only). |
collidesWith | Set<string> | Groups this collider reacts to (read-only). |
size | Vector2 | Bounding dimensions of the shape. Diameter × diameter for circles. |
Enable
gameConfig.testOptions.showColliders = true to visualize collision shapes during development.RayCast — <ray-cast>
RayCast — <ray-cast>
Class:
RayCast · Enum: PrimaryNode.RayCast · JSX tag: <ray-cast>RayCast projects a line segment from the node’s world position to position + direction. Each frame the collision system checks whether any registered collider in the collidesWith groups intersects the ray. When the first intersecting collider changes, colliderEntered and colliderExited fire.Props
The relative endpoint from the ray’s origin. A
Vector2(100, 0) casts 100 px to the right. The length of this vector determines how far the ray reaches.Groups to detect. Only colliders belonging to these groups will trigger events.
Local offset of the ray’s origin. Defaults to
Vector2.ZERO.Events
| Event | useEvent name | Callback | Description |
|---|---|---|---|
colliderEntered | 'colliderEntered' | (collider: Collider) => void | Fires when the first collider the ray hits changes (or a new one is detected). |
colliderExited | 'colliderExited' | (collider: Collider) => void | Fires when the previously detected collider is no longer in range. |
Methods
| Method | Signature | Description |
|---|---|---|
getCollider | () => Collider | null | Returns the currently detected collider, or null if the ray hits nothing. |
Instance properties
| Property | Type | Description |
|---|---|---|
direction | Vector2 | The current direction vector. Mutable. |
collidesWith | string[] | Groups the ray detects (read-only). |
length | number | Euclidean length of the direction vector (read-only). |
Enable
gameConfig.testOptions.showRayCasts = true to visualize ray directions during development.Clickable — <clickable>
Clickable — <clickable>
Class:
Events (
Clickable · Enum: PrimaryNode.Clickable · JSX tag: <clickable>Clickable performs rectangular hit-testing against the pointer each frame. It exposes four interaction events: enter, exit, click (pointer-up inside area), and mouseOver (every frame while hovered). Callback props (onClick, onMouseEnter, onMouseExit, onMouseOver) are convenience shorthand for the equivalent useEvent subscriptions.Props
Dimensions of the hit area
[width, height]. There is no default — size must always be provided.When
true, all interaction events are suppressed. Defaults to false.Local offset of the hit area’s top-left corner. Defaults to
Vector2.ZERO.Callback props (shorthand)
These JSX props attach listeners directly withoutuseEvent:| Prop | Signature | Description |
|---|---|---|
onClick | (position: Vector2) => void | Fired on pointer-up inside the area. |
onMouseEnter | () => void | Fired when the pointer enters the area. |
onMouseExit | () => void | Fired when the pointer leaves the area. |
onMouseOver | (position: Vector2) => void | Fired every frame while the pointer is inside the area. |
Events (useEvent)
| Event | useEvent name | Callback | Description |
|---|---|---|---|
clicked | 'clicked' | (position: Vector2) => void | Pointer released inside the hit area. Position is local to the node’s top-left corner. |
mouseEntered | 'mouseEntered' | () => void | Pointer entered the hit area. |
mouseExited | 'mouseExited' | () => void | Pointer left the hit area. |
mouseOver | 'mouseOver' | (position: Vector2) => void | Every frame while the pointer is inside the area. Position is local. |
Instance properties
| Property | Type | Description |
|---|---|---|
size | Vector2 | Current hit area dimensions. |
disabled | boolean | Whether interaction is suppressed. |
Enable
gameConfig.testOptions.showClickables = true to visualize hit areas during development. Disabled areas render in a muted yellow; active areas in a bright yellow.RigidBody — <rigid-body>
RigidBody — <rigid-body>
Class:
RigidBody · Enum: PrimaryNode.RigidBody · JSX tag: <rigid-body>RigidBody adds physics simulation — gravity, velocity integration, and collision response — to a sibling <collider>. It must be placed as a sibling (not a child) of a Collider node inside the same parent. Gravity defaults to 980 px/s² downward. Use physicsBody to apply forces and impulses programmatically.For full physics documentation see the Physics guide.Props
Mass of the physics body. Heavier bodies are less affected by forces.
0 means infinite mass (behaves like static). Defaults to 1.Friction coefficient
0–1. 0 = frictionless, 1 = maximum friction. Defaults to 0.1.Restitution / bounce coefficient
0–1. 0 = no bounce, 1 = perfectly elastic. Defaults to 0.When
true, the body never moves regardless of forces. Use for immovable terrain. Defaults to false.When
false, gravity is not applied to this body. Defaults to true.Instance properties
| Property | Type | Description |
|---|---|---|
physicsBody | PhysicsBody | The underlying physics body. Use this to apply forces and impulses. |
PhysicsBody methods
| Method | Signature | Description |
|---|---|---|
applyForce | (force: Vector2) => void | Applies a continuous force each frame (acceleration-based). |
applyImpulse | (impulse: Vector2) => void | Applies an instant velocity change. |
setVelocity | (velocity: Vector2) => void | Directly sets the body’s velocity vector. |
Camera — <camera>
Camera — <camera>
Class:
Camera · Enum: PrimaryNode.Camera · JSX tag: <camera>Camera controls the viewport by translating and scaling the canvas context around a target. Place the <camera> at the root of your scene and nest all game-world content inside it. Children are rendered in the camera’s transformed space. Use follow(target) to track a moving node.For full camera documentation see the Camera guide.Props
Viewport scale factor.
1 = no zoom, 2 = everything appears twice as large, 0.5 = zoomed out. Defaults to 1.Camera position in world space. Used when not following a target. Defaults to
Vector2.ZERO.Methods
| Method | Signature | Description |
|---|---|---|
follow | (target: Node2D) => void | Makes the camera center on target’s world position each frame. |
follow | (target: undefined) => void | Stops following; camera returns to its position prop. |
Instance properties
| Property | Type | Description |
|---|---|---|
zoom | number | Get/set the current zoom level. |
Events
Inherits all shared Node2D events:started, updated, drawed, destroyed.