Building a well-structured scene in Engine.js is straightforward once you understand how objects are layered, how the Attributes panel maps to each figure’s properties, and when to involve the physics system. This page walks through the recommended end-to-end workflow, from planning your scene to iterating on it after a live test.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.
Recommended Workflow
Plan your scene
Before placing any objects, sketch out the structure of your scene on paper or in your head. Decide which elements are background (static scenery), which are interactive (platforms, characters, collectibles), and which are foreground or UI overlays. This planning step prevents expensive re-ordering later, because layer order in Engine.js is determined by insertion order.
Add background objects first
Objects added to the scene first are rendered at the bottom of the layer stack (index 0). Add your floor tiles, walls, and static backdrop squares before adding any character or interactive objects. Use the Add Square button (
#agregarCuadro) for rectangular shapes or Add Circle (#agregarCirculo) for round shapes. Background objects are typically large, non-rigid, and positioned to fill the edges of the canvas.Configure transforms
Select each object in the Hierarchy panel to open its Attributes. Use the number inputs for X, Y, Anchura (width), and Altura (height) to position and size the object precisely. For circles, set the Radio (radius) instead of width and height. Every keystroke updates the canvas live via
$g.Dibujar(), so you see changes instantly without pressing Play.Add images for visual objects
To replace a solid-color fill with a graphic, check the Imagen checkbox in the Attributes panel for that figure. A file picker appears — select a local image file. The engine loads it as an
HTMLImageElement and wraps it in a $g.Imagen instance attached to the figure’s transform. The figure type automatically updates to imagen when a file is loaded.Only square and image-type figures support the Image option; circles use their fill color only.Configure sprite animations
If the image you loaded is a sprite sheet (a grid of animation frames), enable the Sprite toggle beneath the image preview. Fill in the following fields to describe the sheet layout:
All five values are required and are applied together so that partially filled fields do not cause inconsistent state.
| Field | Description |
|---|---|
| Número de hilera | Which row of frames to animate (1-based) |
| Número de columnas | Total columns (frames) across the sheet |
| Altura (Sprite individual) | Pixel height of a single frame |
| Anchura (Sprite individual) | Pixel width of a single frame |
| Velocidad (Segundos por frame) | Delay between frames — lower = faster |
Attach physics
Enable the Rígido checkbox for any figure that should respond to gravity and collide with other objects. Once enabled, the Gravedad (gravity) input appears. Set an appropriate value for the feel you want:
0.1— floaty / space-like0.5— normal, earthlike gravity1.0+ — heavy, fast-falling objects
Add sound effects
Check the Sonido checkbox in the Attributes panel to attach audio to a figure. Upload an audio file and choose how it activates using the Tipo de activación dropdown:
Collision-based audio modes require the figure to also have Rígido enabled — without a rigid body, collision events are never fired.You can also set a Global Audio track using the volume icon in the toolbar. This track plays continuously whenever the scene is running and pauses when you press Pause.
| Activation Mode | When it plays |
|---|---|
inicial | As soon as the simulation starts |
colision | When this figure collides with another |
colisionInversa | When this figure stops colliding (leaves contact) |
Test with Play
Press the Play button in the header to start the simulation. The animation loop begins, physics simulate each frame, sprite animations advance, and sounds trigger according to their activation modes. Note that the Attributes panel is hidden and objects cannot be selected or edited while the simulation is running — this is by design to prevent mid-simulation state corruption.
Layer Ordering Strategy
Engine.js renders figures in the order they appear in the$g.figuras array. Index 0 is drawn first (furthest back), and the last index is drawn on top. A practical three-tier approach works well for most scenes:
| Tier | Layer position | Examples |
|---|---|---|
| Background | Bottom (index 0+) | Sky, ground, walls, backdrops |
| Interactive | Middle | Player character, enemies, platforms, collectibles |
| Foreground / UI | Top (highest index) | Score overlays, front-of-scene decorations |
Using the Layout Switcher
The Window icon button (bottom-left toolbar) cycles through three canvas layout presets:- Default — canvas centered, hierarchy on the left, attributes on the right
- Canvas Right — canvas moves to the right side of the workspace
- Canvas Left — canvas moves to the left side of the workspace
localStorage and restored on the next page load.
Physics Gravity Value Guidance
Gravity is applied per-object, not globally. This means different objects in the same scene can fall at different rates — useful for feathers vs. boulders, or for layered parallax effects.0.5 and adjust in increments of 0.1 while testing with Play, rather than jumping straight to extreme values.