Windows Animation / sprite change with sprite_index

A

anjai

Guest
Hi, I have two moving objects in my document: obj_playerA and obj_playerB (playerA sticks to the bottom and and playerB to the top, both can only move left, right or jump).

I used the same animation code for both, except for small changes, like any vertical stuff. For some reason it works for playerA but not for playerB. The "falling animation" (jumping) part works for both tho. To be more specific, it doesn't change the sprite "spr_playerB_stand" to "spr_playerB_run", when moving left or right. I tried deleting the entire animation code from playerA but still playerB won't change sprites, when moving left or right. The sprites are spelled correctly. I'm not getting any error-reports. If anyone could help me, I would be incredibly thankful.

#region Animation

//Falling animation

if (!place_meeting(x, y+1, obj_wall))
{
sprite_index = spr_playerB_jump;
image_speed = 0;
if (sign(vsp) < 0) image_index = 1; else image_index = 0;
}

// Running animation
else
{
image_speed = 1;
if (hsp == 0)
{
sprite_index = spr_playerB_stand;
}
else
{
sprite_index = spr_playerB_run;
}
}

if (hsp != 0) image_xscale = sign(hsp);

#endregion
 
Top