sprite_index (GML)

( Game Maker 6.1, 7 )

sprite_index - currently displayed sprite.

Description

sprite_index is a local object variable that contains the name of the currently displayed sprite of that object. It can be used to set or change the sprite of an object.

When using sprite_index keep in mind that a sprite in Game Maker can have several subimages. If you want to set a specific image to be displayed, also use image_index.

Whenever you need to change the sprite, for example, to make a character face left or right, you can change the sprite_index depending on another variable which indicates which way a game object or character is facing.

Examples

GML Code Examples

Change the Sprite of an Instance

The GML code below will change the sprite of an instance from it's current sprite to spr_other_sprite.

sprite_index = spr_other_sprite;

Related Pages

Actions That Can Change sprite_index

Other

Backlinks

These pages link back to this page. You may find them useful.

To Do

  • sprite_index needs examples
This page is a stub. You can help improve Game Maker Wiki Complete by expanding it.
page_revision: 3, last_edited: 1212351451|%e %b %Y, %H:%M %Z (%O ago)