K
Krinkles
Guest
I've got a sprite set up that's asymmetrical; the character is in a space suit that has different badges on their left and right arms, and a name tag that's on the left side of their chest.
So far, I've figured out some code that makes the sprite facing change according to the character's movement, but I'm stuck on what to do about his facing while he's not moving, or while he's jumping in place. As it is, when he's doing either, he just plays the walk animation for his last facing in either situation. I need a way to make him idle left/right or use the appropriate left/right facing sprites while jumping strait up.
For all intents and purposes I had no prior coding experience before last week.
This is my current animation code. He moves around fine both with and without it, so I don't think his movement/collision codes are relevant.
///Animation
if (sign(hsp)!=0)
{
if (sign(vsp)==0)
{
if (sign(hsp)>0)
{
if (key_sprint)sprite_index = Run_Right1;
else sprite_index = Walk_Right1;
if (sign(hsp)==0) sprite_index = Idle_Right1
}
if (sign(hsp)<0)
{
if (key_sprint)sprite_index = Run_Left1;
else sprite_index = Walk_Left1;
if (sign(hsp)==0) sprite_index = Idle_Left1
}
}
else
{
if (sign(hsp)>0) sprite_index = Jumping_Right1;
if (sign(hsp)<0) sprite_index = Jumping_Left1;
}
}
So far, I've figured out some code that makes the sprite facing change according to the character's movement, but I'm stuck on what to do about his facing while he's not moving, or while he's jumping in place. As it is, when he's doing either, he just plays the walk animation for his last facing in either situation. I need a way to make him idle left/right or use the appropriate left/right facing sprites while jumping strait up.
For all intents and purposes I had no prior coding experience before last week.
This is my current animation code. He moves around fine both with and without it, so I don't think his movement/collision codes are relevant.
///Animation
if (sign(hsp)!=0)
{
if (sign(vsp)==0)
{
if (sign(hsp)>0)
{
if (key_sprint)sprite_index = Run_Right1;
else sprite_index = Walk_Right1;
if (sign(hsp)==0) sprite_index = Idle_Right1
}
if (sign(hsp)<0)
{
if (key_sprint)sprite_index = Run_Left1;
else sprite_index = Walk_Left1;
if (sign(hsp)==0) sprite_index = Idle_Left1
}
}
else
{
if (sign(hsp)>0) sprite_index = Jumping_Right1;
if (sign(hsp)<0) sprite_index = Jumping_Left1;
}
}