EveryDocumentation 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 carries exactly one Transform. It is the object the engine reads every frame to decide where to draw a figure and how it should look. Position coordinates, pixel dimensions, fill color, an optional image or sprite, and an optional sound effect are all consolidated into a single Transform instance. Understanding its properties is essential for placing and styling anything on the canvas.
Constructor
The horizontal canvas coordinate of the figure’s origin, in pixels. For rectangles this is the left edge; for circles it is the centre point.
The vertical canvas coordinate of the figure’s origin, in pixels. For rectangles this is the top edge; for circles it is the centre point. Physics moves this value downward each frame.
Height of the figure in pixels. Used by
'cuadrado' figures for fillRect() and by physics to calculate floor boundaries. Ignored for 'circulo' figures when radio is set (see below).Width of the figure in pixels. Used by
'cuadrado' figures for fillRect() and by collision checks. Ignored for 'circulo' figures when radio is set.Radius in pixels for
'circulo' figures. When this value is non-zero, the constructor automatically sets both anchura and altura to the same value as radio, making the collision bounding box match the visible circle.A CSS color string applied as
fillStyle before drawing. Accepts any valid CSS color value: hex strings ('#ff0000'), named colors ('red'), rgb()/rgba() notation, etc.An
Imagen instance (optionally containing a Sprite) used when the parent figure’s tipo is 'imagen'. Leave as null for 'circulo' and 'cuadrado' figures — the engine ignores this property for those types.A
Sonido instance that attaches audio to this figure. The engine triggers playback based on the Sonido.activacion mode: 'inicial' (plays on loop start), 'colision' (plays while colliding), or 'colisionInversa' (plays while airborne). See Sound for details.Examples by Shape Type
Circle Transform
Rectangle Transform
Static Image Transform
transform.anchura and transform.altura as the destination dimensions to drawImage(), so you can scale the image up or down by changing those values.
Sprite Transform
Transform with Sound
Moving a Figure at Runtime
Becausetransform is a plain object, you can update x and y directly at any time — even inside a custom loop or event handler — and the change takes effect on the next drawn frame.
Related
Figures
How Transform fits inside a Figura.
Images & Sprites
Loading and configuring Imagen and Sprite objects.
Sound
Attaching and triggering audio with Sonido.
Transform API Reference
Complete API reference for the Transform class.