Every visible object in an Engine.js scene — a bouncing ball, a moving platform, a character sprite — is aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/OmarMtya/enginejs-module/llms.txt
Use this file to discover all available pages before exploring further.
Figura. A figure bundles three pieces of information together: the type that controls how it is rendered, a Transform that stores position, size, and appearance, and an optional Rigido component that opts the figure into gravity and collision simulation. Figures without a Rigido are purely visual and remain completely stationary unless you move them manually.
Constructor
A unique identifier for this figure. If falsy (omitted,
null, undefined, 0, or empty string), Engine.js generates one automatically via Environment.GenerarId(), producing a string such as "_k7x2mq9az".A human-readable name. If omitted, Engine.js assigns
"Figura N" where N is the current length of Environment.figuras plus one (e.g. "Figura 1", "Figura 2", …).The rendering type. Determines which Canvas API call Engine.js uses to draw the figure each frame.
A
Transform instance carrying position, dimensions, fill color, image, and sound. See Transform for full details.A
Rigido instance that enables gravity and collision for this figure. When null, the figure is drawn but physics are never calculated for it.Figure Types
'circulo' — Circle
A circle is rendered with the Canvas arc() API. Engine.js draws a full circle (0 to 2π) centred at (transform.x, transform.y) with radius transform.radio and filled with transform.relleno.
When
radio is non-zero, Transform automatically sets both anchura and altura to the same value as radio. This means collision checks and floor-clamping use radio as the effective size dimension.'cuadrado' — Rectangle
A rectangle is rendered with the Canvas fillRect() API at position (transform.x, transform.y) with transform.anchura as width and transform.altura as height. A stroke() call is also made each frame, so the rectangle will have a border using the canvas’s current stroke style.
'imagen' — Image or Sprite
An image figure renders a bitmap asset using drawImage(). The transform.imagen property must be set to either an Imagen instance (for static images) or an Imagen instance whose .sprite property holds a Sprite (for animated spritesheets).
Sprite.anchura and Sprite.altura, not from transform.anchura and transform.altura. Floor collision for sprite figures also uses sprite.altura for the boundary calculation. See Images & Sprites for setup details.
Instance Properties
Set by
tocandoRigidos() on the lower figure whenever another figure lands on top of it. Holds a reference to the impacting Figura. This property does not exist until a collision occurs; it is undefined for figures that have never been hit from above. It is used internally to prevent re-applying the velocity transfer on every frame of sustained contact.Instance Methods
afectarGravedad()
Moves the figure downward by rigido.valor pixels and then increases rigido.valor for the next frame:
Rigido and is not currently resting on the floor or another rigid body. You do not need to call it manually.
tocandoFondo()
Returns true if the figure has reached the bottom boundary of the canvas and sets rigido.colision = true. When true is returned, transform.y is clamped to Environment.altura - transform.altura (or Environment.altura - sprite.altura for sprite figures) so the figure never falls below the canvas edge.
tocandoRigidos()
Scans all other figures in Environment.figuras that also have a Rigido (and do not have sinColision = true) and performs an AABB overlap check via the internal Tocando() utility. When an overlap is detected and the other figure is below this one:
- This figure is repositioned immediately above the other figure.
rigido.colisionis set totrue.- The lower figure’s
tocadoPorproperty is set tothis(the impacting figure). - The lower figure inherits this figure’s current
rigido.valor(velocity transfer on impact). - This figure’s
rigido.valoris reset toEnvironment.gravedad.
transform.sonido is present, sound playback is triggered or paused according to the sound’s activacion mode ('colision' plays on contact, 'colisionInversa' plays while airborne).
Purely Visual Figures
Omittingrigido (or passing rigido: null) creates a figure that is drawn every frame but never moved by the physics engine. Use this for backgrounds, HUD elements, or static decorations.
Related
Transform
Position, size, color, image, and sound for every figure.
Physics
Gravity, collision, and the Rigido component.
Images & Sprites
Load static images and animated spritesheets.
Figura API Reference
Complete API reference for the Figura class.