GM: sprite index

From GMpedia.org Wiki

Jump to: navigation, search
The correct title of this article is sprite_index. It appears incorrectly here because of technical restrictions.

sprite_index

Type: variable
Globalism: Local
Editable: Yes

The sprite_index local variable is the variable that defines the Sprite that the object is currently using. When no sprite index is selected for an object, the value of -1 is assigned to sprite_index.

The variable sprite_index contains a real value and not a string value.

Since it is hard to memorize index numbers for each sprite, Game Maker automatically converts any sprite name used outside a comment or a string into a real number, which is the sprite index.

Therefore:

sprite_index=spr_player;

Would assign the the sprite spr_player to object this code has been performed with.

Personal tools