Const// Simple UI overlay that draws on top
<Layer name="ui" z={1000} visible={true}>
<HUD />
<PauseMenu />
</Layer>
// Zoomable / scrollable map area
function MapView() {
const zoom = useSelf(() => ({ scale: 1.8, offset: new LEA.Vector2(120, 80) }));
const matrix = new KMatrix2D();
matrix.translateSelf(zoom.offset.x, zoom.offset.y);
matrix.scaleSelf(zoom.scale, zoom.scale);
return (
<Layer
name="world-map"
z={10}
transform={matrix}
blend="source-over"
>
<BackgroundTiles />
<Player />
<Enemies />
{// Pointer events inside here receive map-local coordinates }
</Layer>
);
}
Defines a named rendering layer with optional transform, blend mode, visibility, and draw order.
<Layer>is a special component that groups its children into a separate rendering pass. It allows you to:z)Coordinate system behavior:
transformis provided, all pointer coordinates delivered tousePointer/useGlobalPointerinside this layer (and its descendants) are automatically transformed into the layer-local coordinate system.usePointeralso happens in layer-local space.transform(identity/default), coordinates remain in world space.Important notes:
<Layer>creates an independent rendering group.<Layer>components with the samenamewill share the same layer configuration (last one wins for most properties).rootFiberof the layer is set to the fiber of the first<Layer name="..."component encountered with that name.<Layer>still participate in normal component lifecycle, ticking, painting, pointer handling, etc.