GetSpriteIndex

Used to find and return the appropriate four letter sprite's image series, which can be assigned to an actor's sprite internal variable.

Note: This feature is for ZScript only.

int GetSpriteIndex(name sprt)

NOTE: The sprite should be defined regularly (can be any actor, or even give the class a dummy state) with the sprite defined to ensure the sprite and frames are loaded correctly. For example, specifying ZOMB A 0 in a dummy state will ensure every frame is correctly loaded for ZOMB. Glitches can occur otherwise, such as using the wrong sprite or more.

Example

The following roughly translates into how sprite frames are normally specified. This is equivalent of using ZOMB A 2 for that point in the state.

TNT1 A 0
{
     sprite = GetSpriteIndex("ZOMB"); // Will override the TNT1, replacing it with ZOMB.
     frame = 0; //Translates to letter A. 1 is B, 2 is C, etc.
     A_SetTics(2);
}

This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.