A sprite sheet is a single image file that contains multiple animation frames arranged in a grid of rows and columns. Instead of loading a separate image for each frame, Engine.js reads one region of the sheet per frame and advances through the columns automatically, producing smooth animation at the speed you configure.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.
Prerequisites
Before adding aSprite, the figure must already have an Imagen attached. The Imagen wraps an HTMLImageElement pointing to your sprite sheet file:
Sprite to drive the animation.
The Sprite constructor
The row index of the animation strip to play, 0-based. Row
0 is the top row of the sprite sheet.Total number of columns in the sprite sheet — i.e. how many frames are in each row.
Height of a single sprite frame in pixels.
Width of a single sprite frame in pixels.
Playback speed expressed as seconds per frame. For example,
0.1 advances one frame every 100 ms (approximately 10 fps).The
row argument to the Sprite constructor is 0-based: the first row is 0, the second is 1, and so on. The editor UI accepts a 1-based value and subtracts 1 before passing it to the constructor, which is why the displayed value and the code value differ by one.Attaching a sprite to a figure
Updating sprite properties at runtime
Because theSprite object is stored as a plain reference, all five properties can be changed at any time:
Removing sprite animation
Setfigura.transform.imagen.sprite to null to stop the frame cycling. The figure continues to display its attached image as a static bitmap:
Running the animation
The sprite advances frames only when the engine simulation loop is running. Call$g.Animar() to start it:
$g.DetenerAnimacion(), the sprite freezes on its current frame. Calling $g.Animar() again resumes playback from where it left off.
Sprite property reference
| Property | Type | Description |
|---|---|---|
sprite.row | number | Active row index (0-based). |
sprite.cols | number | Total number of columns (frames per row). |
sprite.altura | number | Frame height in pixels. |
sprite.anchura | number | Frame width in pixels. |
sprite.velocidad | number | Seconds per frame. |