# SetSpriteShape

## Description

Sets the current 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. If you select no shape (0) then any existing shape will be deleted, and hit testing will use the sprite dimensions instead. Commands that require a shape such as GetspriteCollision will generate a box shape for the sprite if none exists. The shape parameter lets you define what type of bounding box the system should use to detect collisions. Circle will create a perfect circle centered on the sprite's rotation point and big enough to enclose the sprite's visible pixels. Box will create a box around the edges of the sprite, without regard to whether pixels are visible or not. Polygon will create a close fitting convex polygon around the visible pixels of a sprite, with a visible pixel being defined as one with an alpha value greater than 128.
This function will not work on dummy sprites as there is no image to use when calculating a shape, in these cases shapes must be specified manually using SetSpriteShapeBox, SetSpriteShapeCircle, or SetSpriteShapePolygon.
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

SetSpriteShape( iSpriteIndex, shape, shapeID )

void agk::SetSpriteShape( UINT iSpriteIndex, int shape, int shapeID )

SetSpriteShape( iSpriteIndex, shape )

void agk::SetSpriteShape( UINT iSpriteIndex, int shape )

## Parameters

- iSpriteIndex - The ID of the sprite to modify.
- shape - The shape to use for this sprite, 0=no shape, 1=circle, 2=box, 3=polygon
- shapeID - The ID of the shape to change, first shape is ID 1, 0=delete existing shapes and replace them with this new one