Function

getSpriteOutline

(asset: string, frame?: number, RDP?: boolean, epsilon?: number): Polygon

Create an outline in the form of a polygon from a sprite object

param asset- The name of the sprite you want to generate an outline for

param frame- The frame of the sprite that the outline should be taken from

param RDP- Should the function return a simplified polygon

param epsilon- The amount of the polygon that should be reduced

// Create a collider from the sprite
onLoad(() => {
    add([
        sprite("apple"),
        area({shape: getSpriteOutline("apple")}),
        pos(120, 80), // optional position
    ]);
});

returns A polygon comp. // TODO: add since, group and subgroup

kaplay logo

Components

Miscalenous