Skip to main content

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.

Attaching a $g.Rigido to a Figura opts that object into the physics simulation. On every animation frame the engine reads rigido.valor to apply a downward gravity force and checks rigido.sinColision to decide whether overlapping figures should produce a collision response. Physics only runs inside $g.Animar() — a static $g.Dibujar() call does not advance the simulation.

Constructor

new $g.Rigido()
// or
new $g.Rigido({ valor, sinColision })
Both forms are valid. Calling new $g.Rigido() with no arguments uses the engine’s internal defaults for gravity and enables collision detection.
valor
number
The gravity strength applied to this object each frame. Higher values make the object fall faster. The built-in editor exposes this as the Gravedad field. Optional — the engine sets a default when omitted.
sinColision
boolean
When true, this figure participates in gravity simulation but collision detection is skipped — the object passes through others. Defaults to false (collision is active). Note that the editor’s Colisión checkbox maps to the inverse of this property: checking the box sets sinColision = false.

Attaching and Detaching Physics

Assign a Rigido instance directly to figura.rigido at any point before or during the animation loop:
// Attach physics
figura.rigido = new $g.Rigido();

// Remove physics
figura.rigido = null;

Example: Player with gravity, floor without

// A player square that falls under gravity
const player = new $g.Figura({
    tipo: 'cuadrado',
    transform: new $g.Transform({
        x: 100,
        y: 0,
        anchura: 30,
        altura: 30,
        relleno: '#3498db'
    })
});
player.rigido = new $g.Rigido({ valor: 0.5 });
$g.AgregarFigura(player);

// A static floor that participates in collision but doesn't need to fall
const floor = new $g.Figura({
    tipo: 'cuadrado',
    transform: new $g.Transform({
        x: 0,
        y: 400,
        anchura: 600,
        altura: 20,
        relleno: '#2c3e50'
    })
});
floor.rigido = new $g.Rigido({ sinColision: false });
$g.AgregarFigura(floor);

$g.Animar();

Adjusting Gravity at Runtime

Because rigido.valor is a plain number property, you can change it at any time and the physics loop will pick up the new value on the next frame:
// Speed up gravity mid-game
player.rigido.valor = 1.2;

// Temporarily make the object pass through everything
player.rigido.sinColision = true;
Sounds configured with activacion: 'colision' or activacion: 'colisionInversa' require the figure to have rigido set. Without a Rigido component the collision events never fire and the sound will not play.

Build docs developers (and LLMs) love