SetSpriteShapeChain

Description

Overrides the current auto generated shape for use in physics. Normal sprite collision and hit testing does not work with the chain shape, it is only for 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 chain is defined by a set of points (at least 2) 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. Chains are rigid and can be used to create hollow concave polygons, or 2D terrains. Set the loop parameter to 1 to join to two ends of the chain together creating a hollow polygon. 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.

Using a shapeID of 0 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. 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

SetSpriteShapeChain( iSpriteIndex, numPoints, index, loop, x, y, shapeID )

Parameters