SLUDGE

anim


Syntax:

anim (spriteBank, frame [, frame [, frame...]]);

Purpose:

Creates an animation using the sprites in the spriteBank file. There must be at least one frame specified.

Each frame must be either a number (in which case the sprite will appear for one screen update only) or the return value from the wait function (which can be used to specify that a sprite should appear for longer than one screen update).

Valid values for numerical frame parameters (or the first parameter in a call to the wait function) are:

Negative number outside range

Horizontally flipped sprite number 0 from spriteBank

Negative number in range

Horizontally flipped sprite -frame from spriteBank

Positive number in range

Sprite number frame from spriteBank

Positive number outside range

Nothing

(The range of valid numbers is 0 to the number of sprites in spriteBank minus 1.)

Sounds and functions

Sound files and functions may also be put in the list of frames. When a sound file or function is encountered, it is played or called, and then the animation moves to the next frame immediately. Do not put more than one sound or function in a row: Each sound or function must be separated by a frame number (or the wait function).

Return value:

The return value is the animation which has been created. This can then be used as part of a costume or applied to a character using the animate function.

Examples:

animate (ego, anim ('egoPickUp.duc', 0, 1, 2, wait (3, 10), 2, 1));
animate (ego, anim ('egoPickUp.duc', 0, 1, 2, wait (3, 10), 'noise.ogg', 2, 1));

See also:

addCharacter

setCostume

pause