Windows Sprite Tree Order vs ID issue

SOLVED: Of course I messed up! The ID and Sprite Tree Order is still working as always. So sorry, guys. Very embarrassing mistake on my end.


Hello.

I used to be able to draw sprites like this:
draw_sprite(x,y,image_index,sprite_index+1) //+1 is the next sprite within the sprite asset Tree

I do this , so I don't have type out every sprite asset's name

Now, the problem I have is that the Tree Sprite Order is visually different from the ID or integer within the code... let's say my tree looks like this:

Sprite Tree
- sprPlayerIdle
- sprPlayerWalk
- sprPlayerPunch
- sprPlayerJump

in the code I would do this:

if player punches I would draw sprite sprite_index+2 and the Sprite sprPlayerPunch would come up

But it doesn't work any more since I have upgraded to the latest IDE...
now the same code accesses totally different sprites... it looks like the Sprites just changed their code-order but the visual sprite tree looks the same.

Thank you and kind regards
 
Last edited:

TsukaYuriko

☄️
Forum Staff
Moderator
Don't do this to yourself. You're relying on undocumented functionality - essentially a black box - that may change (and, apparently, has changed) without any prior notice and at any given point in time. The end result is the situation you're in right now. If you "fix" this and continue to rely on it, you're setting yourself up for the same situation happening again in the future.

Implement a proper system - for example using an enum and array - and you won't have such issues:
GML:
enum PlayerState
{
    IDLE,
    WALK,
    PUNCH,
    JUMP,
}

sprites[PlayerState.IDLE] = sprPlayerIdle;
sprites[PlayerState.WALK] = sprPlayerWalk;
sprites[PlayerState.PUNCH] = sprPlayerPunch;
sprites[PlayerState.JUMP] = sprPlayerJump;

state = PlayerState.IDLE;

sprite = sprites[state];
 
Don't do this to yourself. You're relying on undocumented functionality - essentially a black box - that may change (and, apparently, has changed) without any prior notice and at any given point in time. The end result is the situation you're in right now. If you "fix" this and continue to rely on it, you're setting yourself up for the same situation happening again in the future.

Implement a proper system - for example using an enum and array - and you won't have such issues:
GML:
enum PlayerState
{
    IDLE,
    WALK,
    PUNCH,
    JUMP,
}

sprites[PlayerState.IDLE] = sprPlayerIdle;
sprites[PlayerState.WALK] = sprPlayerWalk;
sprites[PlayerState.PUNCH] = sprPlayerPunch;
sprites[PlayerState.JUMP] = sprPlayerJump;

state = PlayerState.IDLE;

sprite = sprites[state];
Believe it or not, I started doing the same as you suggested using global.sprList[0...14]=spriteWhatever and got it to work... but the previous ID order was so convenient to use. I hope they will make the Tree Sprite Order reflect the true ID order again (edit: I am wrong. It works like always).

Thank you for your help
 
Last edited:
Top