# SetSpriteShapePolygon

## Description

Overrides the current auto generated shape for use in collision detection, hit testing, and physics. A shape can be set without turning physics on, and by default all sprites are set to use the box shape, which is the fastest to setup. The polygon is defined by a set of points (between 2 and 12) relative to the current sprite's offset. For example, a point of 0,0 would be centered on the sprite's offset point, any other value will be offset from this point. Points are defined one at a time by calling this command multiple times, with index starting at 0. Once the index equals numPoints-1 then the shape will be created using the previously defined points. Once you start defining points you must complete the process by reaching index=numPoints-1 before defining points for any other shape.
By default, setting a shape removes all other shapes assigned to the sprite and replaces it with this one. You can set shapes individually by specifying a shapeID greater than 0. Shape IDs start at 1 for the first shape, with 0 meaning delete all existing shapes before creating a new one at ID 1. This command only changes existing shapes, by default all sprites have a base shape at ID 1. You can add additional shapes by using the AddSpriteShape commands.

## Definition

SetSpriteShapePolygon( iSpriteIndex, numPoints, index, x, y )

void agk::SetSpriteShapePolygon( UINT iSpriteIndex, UINT numPoints, UINT index, float x, float y )

SetSpriteShapePolygon( iSpriteIndex, numPoints, index, x, y, shapeID )

void agk::SetSpriteShapePolygon( UINT iSpriteIndex, UINT numPoints, UINT index, float x, float y, int shapeID )

## Parameters

- iSpriteIndex - The ID of the sprite to modify.
- numPoints - The number of points to use in the polygon, min 2, max 12.
- index - The index of the point to set, if this equals numPoints-1 then the shape will be created
- x - X coordinate of the polygon to be added
- y - Y coordinate of the polygon to be added
- shapeID - The ID of the shape to change, first shape is ID 1, 0=delete existing shapes and replace them with this new one