rect(w: number, h: number, opt?: RectCompOpt): RectComp

Attach and render a rectangle to a Game Object.

paramw- The width of the rectangle.

paramh- The height of the rectangle.

paramopt- Options for the rectangle component. See

const obstacle = add([
    pos(80, 120),
    rect(20, 40),
    outline(4),
    area(),
])

returnsThe rectangle component.