Function

polygon

(pts: Vec2[], opt?: PolygonCompOpt): PolygonComp

Attach and render a polygon to a Game Object.

param pts- The points to render the polygon.

param opt- Options for the polygon component. See

// Make a square the hard way
add([
    pos(80, 120),
    polygon([vec2(0,0), vec2(50,0), vec2(50,50), vec2(0,50)]),
    outline(4),
    area(),
])

returns The polygon comp.

since v3001.0

group Components

kaplay logo

Layer

Miscalenous