Skip to main content

Documentation 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.

Rigido is the physics component that opts a Figura into Engine.js’s gravity and collision system. Attaching a Rigido to a figure causes the animation loop to call afectarGravedad(), tocandoFondo(), and tocandoRigidos() on every frame. Without a Rigido, a figure is purely decorative and ignored by all physics calculations.

Constructor

new Rigido(valor = 9.8, sinColision = false)
valor
number
default:"9.8"
Initial gravity speed in pixels per frame. Each frame that the figure is airborne, afectarGravedad() adds this value to transform.y and then increases it by valor / (Environment.FPS * 100), producing smooth acceleration. A value of 0 creates a figure that never falls and is useful for static platforms.
sinColision
boolean
default:"false"
When true, this figure falls under gravity but does not participate in rigid-body collision resolution with other figures. It is excluded from the figuras.filter() loop inside tocandoRigidos(), so other figures fall through it. Useful for background objects or triggers that should not block movement.

Instance Properties

valor
number
Current gravity speed in pixels per frame. Mutated each frame by afectarGravedad(). After a collision transfers this speed to the struck figure, it is reset to Environment.gravedad.
valorBackup
number
A copy of the valor passed to the constructor. Stored at construction time and available for manual resets, but not used automatically by the engine in the current version.
colision
boolean
true when this figure is currently resting on the floor (tocandoFondo()) or on top of another rigid figure (tocandoRigidos()). While true, the animation loop skips afectarGravedad(). Set back to false as soon as the figure leaves the surface.
sinColision
boolean
Collision passthrough flag. Mirrors the constructor parameter and can be toggled at runtime to dynamically enable or disable collision resolution for this figure.
tocandoPor
null
Reserved field on Rigido. Always null in the current version of Engine.js; it is never assigned after construction. Do not confuse this with Figura.tocadoPor, which is a separate property set directly on the Figura instance by tocandoRigidos() when another figure lands on top of it.
gravedadReiniciada
boolean
Internal one-tick flag. Set to true by tocandoRigidos() at the moment this figure’s gravity is reset after landing on another figure. On the following tick, tocandoRigidos() reads this flag, sets it back to false, and skips setting colision = false — preventing a one-frame flicker where the figure would appear airborne immediately after impact.

Usage Examples

// Default gravity (9.8 px/frame, collisions enabled)
new $g.Rigido()

// Custom gravity speed
new $g.Rigido(5)

// Falls under gravity but passes through all other rigid figures
new $g.Rigido(9.8, true)

// Static platform — never falls, but other figures can land on it
new $g.Rigido(0)
To create a floor-level platform that other figures can stand on, give it new Rigido(0) so afectarGravedad() never changes its y, and keep sinColision at false so incoming figures resolve against it normally.
  • Figura — the game object that owns a Rigido
  • Transform — position and size
  • Sonido — sound triggered by colision state

Build docs developers (and LLMs) love