|sprite||The sprite to retrieve image index of|
|real||Optional: Sets the number of frames to offset the sprite index|
Every instance has a built-in
image_index variable which tracks the animation frame for the sprite assigned to
sprite_index, adjusted for
image_speed. But many objects draw multiple sprites, each of which may have a different speed. This script returns the
image_index value for any sprite, factoring in both sprite speed and delta time.
Note that this script is based on global session time, and will always return the same index at the same time for every instance of the sprite. Sometimes this synchronization is not desirable, in which case an optional offset time can also be supplied, as a value of frames. For example, to base starting time on instance creation time, use
-sprite_get_index() (must be a variable declared in an event that is not run every Step).