Documentation Index
Fetch the complete documentation index at: https://mintlify.com/OmarMtya/engine.js/llms.txt
Use this file to discover all available pages before exploring further.
$g.Sprite tells the engine how to slice a sprite sheet image into individual frames and how fast to play them back. It does not hold image data itself — it is always stored on a $g.Imagen instance via imagen.sprite, and the Imagen must have a valid src before animation can render correctly. Once a Sprite is attached and $g.Animar() is running, the engine automatically advances through the frames each tick.
Constructor
The 0-based row index of the animation strip to play within the sprite sheet. Row
0 is the top row. When you enter a row number in the editor UI the editor shows it as 1-based and subtracts 1 before passing it to the constructor — always use 0-based values when calling the constructor directly.The total number of columns (frames) in the sprite sheet. The engine divides the image width by this number to calculate individual frame width when slicing.
The height of a single frame in pixels. This is the crop height the engine uses when drawing each frame from the sheet.
The width of a single frame in pixels. This is the crop width used when drawing each frame.
Playback speed expressed as seconds per frame. For example,
0.1 plays at roughly 10 fps and 0.033 plays at roughly 30 fps. Smaller values produce faster animations.Prerequisites
Before attaching aSprite, make sure:
- The
Figurahastiposet to'imagen'. figura.transform.imagenis a valid$g.Imageninstance.figura.transform.imagen.srcpoints to a loadedHTMLImageElement.
Examples
Attaching a sprite animation
Switching animation rows at runtime
You can change the active row by mutatingsprite.row directly while the animation loop is running:
Changing playback speed
Removing sprite animation
Settingsprite to null causes the engine to render the full unclipped image instead:
The built-in editor displays row numbers starting at 1 and subtracts 1 internally before assigning to
sprite.row. When calling the constructor directly in code, always pass the 0-based row index. Passing 1 in code selects the second row of the sheet.