Source: resources/modules/xs/components.wren
Component that stores position and rotation for an entity
construct new(position: Vec2) ↗Creates a new Transform at the given position with zero rotation
position -> Vec2 ↗Gets the position as a Vec2
position=(p: Vec2) ↗Sets the position
rotation -> Num ↗Gets the rotation in radians
rotation=(r: Num) ↗Sets the rotation in radians
Component that provides size and velocity for physics-based movement
construct new(size: Vec2, velocity: Vec2) ↗Creates a new Body with the given size and velocity
size -> Vec2 ↗Gets the size of the body
velocity -> Vec2 ↗Gets the velocity as a Vec2
size=(s: Vec2) ↗Sets the size of the body
velocity=(v: Vec2) ↗Sets the velocity
update(dt: Num) ↗Updates the position based on velocity and delta time
Base class for all renderable components with layer-based sorting
construct new() ↗Creates a new Renderable with default layer 0
render() ↗Override this method in subclasses to implement rendering
<(other: Renderable) -> Bool ↗Comparison operator for sorting by layer
layer -> Num ↗Gets the rendering layer (higher values render on top)
layer=(l: Num) ↗Sets the rendering layer
static render() ↗Renders all Renderable components in all entities
Renders a sprite from an image or texture atlas
construct new(image) ↗Creates a sprite from a full image (path or image ID)
construct new(image, s0, t0, s1, t1) ↗Creates a sprite from a section of an image using normalized texture coordinates
construct new(sheetPath, spriteName) ↗Creates a sprite from a spritesheet file (.xssprite) by sprite name
The spritesheet file contains Json with an "image" path and "sprites" definitions
Each sprite has x, y, width, and height in pixels
initialize() ↗Initializes by caching reference to Transform component
render() ↗Renders the sprite at the Transform's position and rotation
add -> Num ↗Gets the additive color (0xRRGGBBAA format)
add=(a: Num) ↗Sets the additive color
mul -> Num ↗Gets the multiply color (0xRRGGBBAA format)
mul=(m: Num) ↗Sets the multiply color
flags -> Num ↗Gets the sprite flags (flipping, centering, etc.)
flags=(f: Num) ↗Sets the sprite flags
scale -> Num ↗Gets the sprite scale
scale=(s: Num) ↗Sets the sprite scale
sprite_=(s: Num) ↗Sets the sprite ID
sprite -> Num ↗Gets the sprite ID
Renders a shape (SVG or custom mesh)
construct new(shape: Num) ↗Creates a Shape component with the given shape ID
render() ↗Renders the shape at the Transform's position and rotation
add -> Num ↗Gets the additive color (0xRRGGBBAA format)
add=(a: Num) ↗Sets the additive color
mul -> Num ↗Gets the multiply color (0xRRGGBBAA format)
mul=(m: Num) ↗Sets the multiply color
flags -> Num ↗Gets the shape flags
flags=(f: Num) ↗Sets the shape flags
scale -> Num ↗Gets the shape scale
scale=(s: Num) ↗Sets the shape scale
shape=(s: Num) ↗Sets the shape ID
shape -> Num ↗Gets the shape ID
Renders text using a loaded font
construct new(font, text: String, size: Num) ↗Creates a Label with the given font (path or font ID), text content, and size
render() ↗Renders the text at the Transform's position
text -> String ↗Gets the text content
text=(t: String) ↗Sets the text content
Sprite that can display frames from a sprite sheet grid
construct new(image, columns: Num, rows: Num) ↗Creates a GridSprite from an image divided into columns and rows
idx=(i: Num) ↗Sets the current frame index
idx -> Num ↗Gets the current frame index
[i: Num] -> Num ↗Gets the sprite ID at the given frame index
Sprite with animation support for playing frame sequences from a sprite sheet
Use addAnimation() to define named animations, then playAnimation() to start them
Call update(dt) each frame to advance the animation
construct new(image, columns: Num, rows: Num, fps: Num) ↗Creates an AnimatedSprite with the given frame rate (frames per second)
fps determines how fast animations play - higher values = faster animations
construct new(sheetPath) ↗Creates an AnimatedSprite from an animation sheet file (.xsanim)
The file contains image path, columns, rows, fps, and animation definitions
update(dt: Num) ↗Updates the animation frame based on delta time
addAnimation(name: String, frames: List) ↗Adds a named animation with a list of frame indices
Frame indices correspond to positions in the sprite sheet (0-indexed, left to right, top to bottom)
Example: addAnimation("walk", [0, 1, 2, 3])
playAnimation(name: String) ↗Plays the animation with the given name, restarting from the first frame
Does nothing if the animation name doesn't exist
randomizeFrame(random: Random) ↗Randomizes the current frame within the current animation
mode -> Num ↗Gets the animation mode
mode=(m: Num) ↗Sets the animation mode (once, loop, or destroy)
isDone -> Bool ↗Checks if animation has finished (for non-looping animations)
static once -> Num ↗Play animation once and stop on the last frame
static loop -> Num ↗Loop animation continuously (default behavior)
static destroy -> Num ↗Delete the owning entity when animation completes (useful for effects)
Makes an entity follow its parent's position with an offset
construct new(parent: Entity) ↗Creates a Relation that follows the given parent entity
update(dt: Num) ↗Updates position to follow parent (with rotation support)
offset -> Vec2 ↗Gets the offset from parent position
offset=(o: Vec2) ↗Sets the offset from parent position
parent -> Entity ↗Gets the parent entity
Deletes this entity when its parent is deleted
construct new(parent: Entity) ↗Creates an Ownership component tied to the given parent entity
update(dt: Num) ↗Checks if parent is deleted and deletes this entity if so
parent -> Entity ↗Gets the parent entity