image_index

A sprite is made up of one or more sub-images which can make the sprite appear animated as they switch from one to the other, or can they can be switched between in code to give different "states", much like a button has in windows. If the sprite is animated, then you can get the current frame of the animation by checking the image_index variable, or if you want to change the state of a static sprite, you can select a new sub-image by setting this variable to the desired sub-image of the sprite.

Usage Notes

 

Syntax:

image_index;

 

Returns:

Real (single precision floating point value)

 

Example:

if (image_speed > 0)
{
    if (image_index >= image_number - 1) instance_destroy();
}

The above code checks to see if the sprite is animating, and if it is then it checks to see if the current image_index is at the last frame and in that case destroys the instance.