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.


SetSpriteShape( iSpriteIndex, shape, shapeID )

SetSpriteShape( iSpriteIndex, shape )