# SetSpriteShapeBox

## 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 box is defined by specifying its top left and bottom right coordinates in sprite space, relative to the offset of the sprite, by default this is the center of the sprite. For example if the current sprite offset was 0,0 the top left box corner would be 0,0, but if the sprite offset was the middle of the sprite (default) the top left corner would be -width/2,-height/2. You may also specify an angle to offset the box relative to the current sprite rotation.
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

SetSpriteShapeBox( iSpriteIndex, x, y, x2, y2, angle, shapeID )

void agk::SetSpriteShapeBox( UINT iSpriteIndex, float x, float y, float x2, float y2, float angle, int shapeID )

SetSpriteShapeBox( iSpriteIndex, x, y, x2, y2, angle )

void agk::SetSpriteShapeBox( UINT iSpriteIndex, float x, float y, float x2, float y2, float angle )

## Parameters

- iSpriteIndex - The ID of the sprite to modify.
- x - The X coordinate of the top left corner of the new box in sprite space.
- y - The Y coordinate of the top left corner of the new box in sprite space.
- x2 - The X coordinate of the bottom right corner of the new box in sprite space.
- y2 - The Y coordinate of the bottom right corner of the new box in sprite space.
- angle - The angle of the box in radians.
- shapeID - The ID of the shape to change, first shape is ID 1, 0=delete existing shapes and replace them with this new one